2 * << Haru Free PDF Library >> -- hpdf_error.c
4 * URL: http://libharu.org
6 * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
7 * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
9 * Permission to use, copy, modify, distribute and sell this software
10 * and its documentation for any purpose is hereby granted without fee,
11 * provided that the above copyright notice appear in all copies and
12 * that both that copyright notice and this permission notice appear
13 * in supporting documentation.
14 * It is provided "as is" without express or implied warranty.
18 #include "hpdf_conf.h"
19 #include "hpdf_utils.h"
20 #include "hpdf_error.h"
21 #include "hpdf_consts.h"
26 #define HPDF_STDCALL __stdcall
29 #define HPDF_STDCALL __stdcall
37 HPDF_CopyError (HPDF_Error dst,
42 HPDF_Error_Init (HPDF_Error error,
45 HPDF_MemSet(error, 0, sizeof(HPDF_Error_Rec));
47 error->user_data = user_data;
51 HPDF_Error_GetCode (HPDF_Error error)
53 return error->error_no;
57 HPDF_Error_GetDetailCode (HPDF_Error error)
59 return error->detail_no;
63 HPDF_CopyError (HPDF_Error dst,
66 dst->error_no = src->error_no;
67 dst->detail_no = src->detail_no;
68 dst->error_fn = src->error_fn;
69 dst->user_data = src->user_data;
73 HPDF_SetError (HPDF_Error error,
75 HPDF_STATUS detail_no)
77 HPDF_PTRACE((" HPDF_SetError: error_no=0x%04X "
78 "detail_no=0x%04X\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no));
80 error->error_no = error_no;
81 error->detail_no = detail_no;
87 HPDF_EXPORT(HPDF_STATUS)
88 HPDF_CheckError (HPDF_Error error)
90 HPDF_PTRACE((" HPDF_CheckError: error_no=0x%04X detail_no=0x%04X\n",
91 (HPDF_UINT)error->error_no, (HPDF_UINT)error->detail_no));
93 if (error->error_no != HPDF_OK && error->error_fn)
94 error->error_fn (error->error_no, error->detail_no, error->user_data);
96 return error->error_no;
101 HPDF_RaiseError (HPDF_Error error,
102 HPDF_STATUS error_no,
103 HPDF_STATUS detail_no)
105 HPDF_SetError (error, error_no, detail_no);
107 return HPDF_CheckError (error);
112 HPDF_Error_Reset (HPDF_Error error)
114 error->error_no = HPDF_NOERROR;
115 error->detail_no = HPDF_NOERROR;