00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 # include "incls/_precompiled.incl"
00025 # include "incls/_error.cpp.incl"
00026
00027 void report_vm_state() {
00028 #ifdef DEBUG
00029 static bool recursive_error = false;
00030 if (!recursive_error) {
00031 recursive_error = true;
00032 #ifdef DELTA_COMPILER
00033 if (theCompiler) {
00034 std->print("\nThe error happened while compiling ");
00035 theCompiler->print_key(std);
00036 std->cr();
00037 if (CompilerDebug) {
00038 print_cout();
00039 } else {
00040 std->print("(No compiler debug output available -- run with +CompilerDebug to get it)");
00041 }
00042 std->cr();
00043 }
00044 #endif // DELTA_COMPILER
00045
00046 std->print("\nLast 10 internal VM events:\n");
00047 eventLog->printPartial(10);
00048 recursive_error = false;
00049 }
00050 #endif // DEBUG
00051 }
00052
00053 void report_error(char* title, char* format, ...) {
00054 char buffer[2048];
00055 va_list ap;
00056 va_start(ap, format);
00057 vsprintf(buffer, format, ap);
00058 va_end(ap);
00059
00060 std->cr();
00061 std->print_cr("[A Runtime Error Occurred]");
00062 std->print_raw(buffer);
00063
00064 if (!bootstrapping) report_vm_state();
00065
00066 if (ShowMessageBoxOnError) {
00067 strcat(buffer, "\n\nDo you want to debug the problem?");
00068 if (!os::message_box(title, buffer)) os::fatalExit(-1);
00069 }
00070 }
00071
00072 void report_assertion_failure(char* code_str, char* file_name, int line_no, char* message) {
00073 report_error("Assertion Failure", "assert(%s, \"%s\")\n%s, %d",
00074 code_str, message, file_name, line_no);
00075 }
00076
00077 void report_fatal(char* file_name, int line_no, char* format, ...) {
00078 char buffer[2048];
00079 va_list ap;
00080 va_start(ap, format);
00081 vsprintf(buffer, format, ap);
00082 va_end(ap);
00083 report_error("Fatal Error", "Fatal: %s\n%s, %d", buffer, file_name, line_no);
00084 }
00085
00086 void report_should_not_call(char* file_name, int line_no) {
00087 report_error("Should Not Call This Error", "ShouldNotCall()\n%s, %d",
00088 file_name, line_no);
00089 }
00090
00091 void report_should_not_reach_here(char* file_name, int line_no) {
00092 report_error("Should Not Reach Here Error", "ShouldNotReachHere()\n%s, %d",
00093 file_name, line_no);
00094 }
00095
00096 void report_subclass_responsibility(char* file_name, int line_no) {
00097 report_error("Subclass Responsibility Error", "SubclassResponsibility()\n%s, %d",
00098 file_name, line_no);
00099 }
00100
00101 void report_unimplemented(char* file_name, int line_no) {
00102 report_error("Unimplemented Error", "Unimplemented()\n%s, %d", file_name, line_no);
00103 }
00104