#include <myexcept.h>
Inheritance diagram for Exception:

Public Member Functions | |
| Exception (const char *a_what=0) | |
Static Public Member Functions | |
| void | AddMessage (const char *a_what) |
| void | AddInt (int value) |
| const char * | what () |
Static Public Attributes | |
| unsigned long | Select |
Static Protected Attributes | |
| char * | what_error |
| int | SoFar |
| int | LastOne |
|
|
Definition at line 47 of file myexcept.cpp. References AddMessage(), Tracer::AddTrace(), LastOne, Select, SoFar, and what_error.
00048 {
00049 Select++; SoFar = 0;
00050 if (!what_error) // make space for exception message
00051 {
00052 LastOne = 511;
00053 what_error = new char[512];
00054 if (!what_error) // fail to make space
00055 {
00056 LastOne = 0;
00057 what_error = "No heap space for exception message\n";
00058 }
00059 }
00060 AddMessage("\n\nAn exception has been thrown\n");
00061 AddMessage(a_what);
00062 if (a_what) Tracer::AddTrace();
00063 }
|
|
|
Definition at line 80 of file myexcept.cpp. References AddMessage(), LastOne, SoFar, and what_error.
00081 {
00082 bool negative;
00083 if (value == 0) { AddMessage("0"); return; }
00084 else if (value < 0) { value = -value; negative = true; }
00085 else negative = false;
00086 int n = 0; int v = value; // how many digits will we need?
00087 while (v > 0) { v /= 10; n++; }
00088 if (negative) n++;
00089 if (LastOne-SoFar < n) { AddMessage("***"); return; }
00090
00091 SoFar += n; n = SoFar; what_error[n] = 0;
00092 while (value > 0)
00093 {
00094 int nv = value / 10; int rm = value - nv * 10; value = nv;
00095 what_error[--n] = (char)(rm + '0');
00096 }
00097 if (negative) what_error[--n] = '-';
00098 return;
00099 }
|
|
|
Definition at line 65 of file myexcept.cpp. References LastOne, SoFar, and what_error. Referenced by AddInt(), Tracer::AddTrace(), Bad_alloc::Bad_alloc(), Bad_cast::Bad_cast(), Bad_typeid::Bad_typeid(), Domain_error::Domain_error(), Exception(), Invalid_argument::Invalid_argument(), Length_error::Length_error(), Logic_error::Logic_error(), Out_of_range::Out_of_range(), Overflow_error::Overflow_error(), Range_error::Range_error(), and Runtime_error::Runtime_error().
00066 {
00067 if (a_what)
00068 {
00069 int l = strlen(a_what); int r = LastOne - SoFar;
00070 if (l < r) { strcpy(what_error+SoFar, a_what); SoFar += l; }
00071 else if (r > 0)
00072 {
00073 strncpy(what_error+SoFar, a_what, r);
00074 what_error[LastOne] = 0;
00075 SoFar = LastOne;
00076 }
00077 }
00078 }
|
|
|
Definition at line 81 of file myexcept.h. Referenced by Terminate().
00081 { return what_error; }
|
|
|
Definition at line 45 of file myexcept.cpp. Referenced by AddInt(), AddMessage(), and Exception(). |
|
|
Reimplemented in Logic_error, Runtime_error, Domain_error, Invalid_argument, Length_error, Out_of_range, Bad_cast, Bad_typeid, Range_error, Overflow_error, and Bad_alloc. Definition at line 42 of file myexcept.cpp. Referenced by Bad_alloc::Bad_alloc(), Bad_cast::Bad_cast(), Bad_typeid::Bad_typeid(), Domain_error::Domain_error(), Exception(), Invalid_argument::Invalid_argument(), Length_error::Length_error(), Logic_error::Logic_error(), Out_of_range::Out_of_range(), Overflow_error::Overflow_error(), Range_error::Range_error(), and Runtime_error::Runtime_error(). |
|
|
Definition at line 44 of file myexcept.cpp. Referenced by AddInt(), AddMessage(), and Exception(). |
|
|
Definition at line 43 of file myexcept.cpp. Referenced by AddInt(), AddMessage(), and Exception(). |
1.3.3