2009-09-12 Chris Toshok <toshok@ximian.com>
[moon.git] / src / error.cpp
blobfca6cbb5e7746f4e211d8235482b656644fa5168
1 /*
2 * error.cpp: ErrorEventArgs and its subclasses
4 * Contact:
5 * Moonlight List (moonlight-list@lists.ximian.com)
7 * Copyright 2007 Novell, Inc. (http://www.novell.com)
9 * See the LICENSE file included with the distribution for details.
13 #include "error.h"
16 // ErrorEventArgs
18 ErrorEventArgs::ErrorEventArgs (Type::Kind kind, ErrorType type, int code, const char *msg)
19 : EventArgs (kind)
21 error_type = type;
22 error_code = code;
23 error_message = g_strdup (msg);
24 extended_message = NULL;
25 extended_code = 0;
28 ErrorEventArgs::ErrorEventArgs (ErrorType type, int code, const char *msg)
29 : EventArgs (Type::ERROREVENTARGS)
31 error_type = type;
32 error_code = code;
33 error_message = g_strdup (msg);
34 extended_message = NULL;
35 extended_code = 0;
38 ErrorEventArgs::ErrorEventArgs (ErrorType type, int code, const char *msg, int extended_error_code, const char *extended_msg)
39 : EventArgs (Type::ERROREVENTARGS)
41 error_type = type;
42 error_code = code;
43 error_message = g_strdup (msg);
44 extended_message = g_strdup (extended_msg);
45 extended_code = extended_error_code;
48 ErrorEventArgs::~ErrorEventArgs ()
50 g_free (error_message);
51 g_free (extended_message);
56 // ImageErrorEventArgs
59 ImageErrorEventArgs::ImageErrorEventArgs (const char *msg)
60 : ErrorEventArgs (Type::IMAGEERROREVENTARGS, ImageError, 4001, msg)
64 ImageErrorEventArgs::~ImageErrorEventArgs ()
70 // ParserErrorEventArgs
73 ParserErrorEventArgs::ParserErrorEventArgs (const char *msg, const char *file,
74 int line, int column, int error_code,
75 const char *element, const char *attribute)
76 : ErrorEventArgs (Type::PARSERERROREVENTARGS, ParserError, error_code, msg)
78 xml_attribute = g_strdup (attribute);
79 xml_element = g_strdup (element);
80 xaml_file = g_strdup (file);
81 char_position = column;
82 line_number = line;
85 ParserErrorEventArgs::~ParserErrorEventArgs ()
87 g_free (xaml_file);
88 g_free (xml_element);
89 g_free (xml_attribute);
93 // MoonError
96 MoonError::MoonError ()
98 number = (ErrorType) 0;
99 code = 0;
100 message = 0;
101 char_position = -1;
102 line_number = -1;
103 gchandle_ptr = NULL;
106 MoonError::~MoonError ()
108 g_free (message);
109 message = NULL;
112 void
113 MoonError::Clear ()
115 number = NO_ERROR;
116 code = 0;
117 g_free (message);
118 message = NULL;
121 void
122 MoonError::FillIn (MoonError *error, ErrorType number, int code, char *message)
124 if (!error)
125 return;
127 error->number = number;
128 error->code = code;
129 error->message = message;
132 void
133 MoonError::FillIn (MoonError *error, ErrorType number, int code, const char *message)
135 if (!error)
136 return;
138 FillIn (error, number, code, g_strdup (message));
141 void
142 MoonError::FillIn (MoonError *error, ErrorType type, char *message)
144 if (!error)
145 return;
147 FillIn (error, type, 0, message);
150 void
151 MoonError::FillIn (MoonError *error, ErrorType type, const char *message)
153 if (!error)
154 return;
156 FillIn (error, type, 0, message);
160 void
161 MoonError::SetXamlPositionInfo (MoonError *error, int char_position, int line_number)
163 if (!error)
164 return;
165 error->char_position = char_position;
166 error->line_number = line_number;