2009-12-01 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / error.cpp
blob8c7d209010210048794eb986b83e3ca755b250d3
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 <config.h>
16 #include "error.h"
17 #include "eventargs.h"
20 // MoonError
23 MoonError::MoonError ()
25 number = (ExceptionType) 0;
26 code = 0;
27 message = 0;
28 char_position = -1;
29 line_number = -1;
30 gchandle_ptr = NULL;
33 MoonError::MoonError (ExceptionType type, int code, const char *message)
35 this->number = type;
36 this->code = code;
37 this->message = g_strdup (message);
38 char_position = -1;
39 line_number = -1;
40 gchandle_ptr = NULL;
43 MoonError::MoonError (const MoonError &e)
45 number = e.number;
46 code = e.code;
47 message = g_strdup (e.message);
48 char_position = e.char_position;
49 line_number = e.line_number;
50 gchandle_ptr = e.gchandle_ptr;
53 MoonError::~MoonError ()
55 Clear ();
58 void
59 MoonError::Clear ()
61 number = NO_ERROR;
62 code = 0;
63 g_free (message);
64 message = NULL;
67 MoonError&
68 MoonError::operator= (const MoonError& other)
70 number = other.number;
71 code = other.code;
72 message = g_strdup (other.message);
73 char_position = other.char_position;
74 line_number = other.line_number;
75 gchandle_ptr = other.gchandle_ptr;
76 return *this;
79 void
80 MoonError::FillIn (MoonError *error, ExceptionType number, int code, const char *message)
82 if (!error)
83 return;
85 error->number = number;
86 error->code = code;
87 error->message = g_strdup (message);
90 void
91 MoonError::FillIn (MoonError *error, ExceptionType type, const char *message)
93 if (!error)
94 return;
96 FillIn (error, type, 0, message);
100 void
101 MoonError::FillIn (MoonError *error, ParserErrorEventArgs *error_args)
103 if (!error)
104 return;
105 FillIn (error, MoonError::XAML_PARSE_EXCEPTION, error_args->GetErrorMessage());
106 error->char_position = error_args->char_position;
107 error->line_number = error_args->line_number;