/[pearpc]/src/tools/except.cc
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /src/tools/except.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Wed Sep 5 17:11:21 2007 UTC (11 years, 10 months ago) by dpavlin
File size: 2983 byte(s)
import upstream CVS
1 /*
2 * HT Editor
3 * except.cc
4 *
5 * Copyright (C) 1999-2002 Stefan Weyergraf
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include <cstdio>
22 #include <cstdarg>
23 #include <cstring>
24
25 #include "except.h"
26 #include "snprintf.h"
27
28 /*
29 * class Exception
30 */
31
32 Exception::Exception() throw()
33 {
34 }
35
36 Exception::~Exception()
37 {
38 }
39
40 String &Exception::reason(String &result) const
41 {
42 result = "Unknown Exception";
43 return result;
44 }
45
46 /*
47 * class MsgException
48 */
49 MsgException::MsgException() throw()
50 {
51 }
52
53 MsgException::MsgException(const char *e) throw()
54 {
55 strncpy(estr, e, sizeof estr-1);
56 estr[sizeof estr-1] = 0;
57 }
58
59 String &MsgException::reason(String &result) const
60 {
61 result = estr;
62 return result;
63 }
64
65 /*
66 * class MsgfException
67 */
68 MsgfException::MsgfException(const char *e,...) throw()
69 {
70 va_list va;
71 va_start(va, e);
72 ht_vsnprintf(estr, sizeof estr, e, va);
73 va_end(va);
74 }
75
76 /*
77 * class IOException
78 */
79
80 //#include <signal.h>
81 IOException::IOException(int aPosixErrno) throw()
82 {
83 mPosixErrno = aPosixErrno;
84 errstr = strerror(mPosixErrno);
85 // raise(SIGTRAP);
86 }
87
88 IOException::~IOException()
89 {
90 }
91
92 String &IOException::reason(String &result) const
93 {
94 result = "I/O error: " + errstr;
95 return result;
96 }
97
98 /*
99 * class NotImplementedException
100 */
101
102 NotImplementedException::NotImplementedException(const String &filename, int line_number) throw()
103 {
104 if (line_number) {
105 location.assignFormat("%y:%d", &filename, line_number);
106 } else {
107 location = filename;
108 }
109 }
110
111 String &NotImplementedException::reason(String &result) const
112 {
113 result = "Function not implemented";
114 if (!location.isEmpty()) result += ": "+location;
115 return result;
116 }
117
118 /*
119 * class IllegalArgumentException
120 */
121
122 IllegalArgumentException::IllegalArgumentException(const String &filename, int line_number) throw()
123 {
124 if (line_number) {
125 location.assignFormat("%y:%d", &filename, line_number);
126 } else {
127 location = filename;
128 }
129 }
130
131 String &IllegalArgumentException::reason(String &result) const
132 {
133 result = "Illegal argument";
134 if (!location.isEmpty()) result += ": "+location;
135 return result;
136 }
137
138 /*
139 * class TypeCastException
140 */
141
142 TypeCastException::TypeCastException(const String &cast_type, const String &obj_type) throw()
143 {
144 aresult.assignFormat("(%y) %y", &cast_type, &obj_type);
145 }
146
147 String &TypeCastException::reason(String &result) const
148 {
149 result = "Bad type cast";
150 if (!aresult.isEmpty()) result += ": "+aresult;
151 return result;
152 }
153

  ViewVC Help
Powered by ViewVC 1.1.26