1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif /* Def: HAVE_CONFIG_H */
4
5 #include "exception.h"
6
7 at_exception_type
at_exception_new(at_msg_func client_func,at_address client_data)8 at_exception_new(at_msg_func client_func,
9 at_address client_data)
10 {
11 at_exception_type e = {0, client_func, client_data};
12 return e;
13 }
14
15 at_bool
at_exception_got_fatal(at_exception_type * exception)16 at_exception_got_fatal(at_exception_type * exception)
17 {
18 return (exception->msg_type == AT_MSG_FATAL);
19 }
20
21 void
at_exception_fatal(at_exception_type * exception,const at_string message)22 at_exception_fatal(at_exception_type * exception,
23 const at_string message)
24 {
25 if (!exception)
26 return;
27 exception->msg_type = AT_MSG_FATAL;
28 if (exception->client_func)
29 {
30 exception->client_func(message,
31 AT_MSG_FATAL,
32 exception->client_data);
33 }
34 }
35
36 void
at_exception_warning(at_exception_type * exception,const at_string message)37 at_exception_warning(at_exception_type * exception,
38 const at_string message)
39 {
40 if (!exception)
41 return;
42 exception->msg_type = AT_MSG_WARNING;
43 if (exception->client_func)
44 {
45 exception->client_func(message,
46 AT_MSG_WARNING,
47 exception->client_data);
48 }
49 }
50