error.cpp

Go to the documentation of this file.
00001 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.5 $ */
00002 /* Copyright (c) 2006, Sun Microsystems, Inc.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 
00006 following conditions are met:
00007 
00008     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 
00010           disclaimer in the documentation and/or other materials provided with the distribution.
00011     * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 
00012           from this software without specific prior written permission.
00013 
00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 
00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
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 

Generated on Mon Oct 9 13:37:09 2006 for Strongtalk VM by  doxygen 1.4.7