pike.git
/
src
/
error.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/error.c:14:
#include "array.h" #include "object.h" #include "main.h" #include "builtin_functions.h" #include "backend.h" #include "operators.h" #include "module_support.h" #include "threads.h" #include "gc.h"
-
RCSID("$Id: error.c,v 1.
68
2001/
01
/
12
02
:
15
:
56
mast
Exp $");
+
RCSID("$Id: error.c,v 1.
69
2001/
02
/
06
19
:
31
:
39
grubba
Exp $");
#undef ATTRIBUTE #define ATTRIBUTE(X) /*
-
+
* Attempt to inhibit throwing of errors if possible.
+
* Used by exit_on_error() to avoid infinite sprintf() loops.
+
*/
+
int Pike_inhibit_errors = 0;
+
+
/*
* Backtrace handling. */ struct pike_backtrace { struct pike_frame *trace; struct pike_frame *iterator; int iterator_index; };
pike.git/src/error.c:423:
in_error=0; pike_throw(); /* Hope someone is catching, or we will be out of balls. */ } PMOD_EXPORT void exit_on_error(void *msg) { ONERROR tmp; SET_ONERROR(tmp,fatal_on_error,"Fatal in exit_on_error!"); d_flag=0;
+
/* Tell sprintf(), describe_svalue() et al not to throw errors
+
* if possible.
+
*/
+
Pike_inhibit_errors = 1;
+
fprintf(stderr,"%s\n",(char *)msg); #ifdef PIKE_DEBUG dump_backlog(); #endif fprintf(stderr,"%s\n",(char *)msg); #ifdef PIKE_DEBUG { char *s; fprintf(stderr,"Attempting to dump raw error: (may fail)\n"); init_buf();
pike.git/src/error.c:518:
write_to_stderr(Pike_sp[-1].u.string->str, Pike_sp[-1].u.string->len); }else{ fprintf(stderr,"No stack - no backtrace.\n"); } fflush(stderr); do_abort(); } #if 1
+
/*! @class Error
+
*/
+
#define ERR_DECLARE #include "errors.h"
-
+
/*! @decl array cast(string type)
+
*!
+
*! Cast operator.
+
*!
+
*! @note
+
*! The only supported type to cast to is @tt{"array"@}, which
+
*! generates and old-style error.
+
*/
void f_error_cast(INT32 args) { char *s; get_all_args("error->cast",args,"%s",&s); if(!strncmp(s,"array",5)) { pop_n_elems(args); ref_push_string(GENERIC_ERROR_THIS->desc); ref_push_array(GENERIC_ERROR_THIS->backtrace); f_aggregate(2); }else{ SIMPLE_BAD_ARG_ERROR("error->cast", 1, "the value \"array\""); } }
-
+
/*! @decl array|string `[](int(0..1) index)
+
*!
+
*! Index operator.
+
*!
+
*! Simulates an array
+
*! @array
+
*! @elem string msg
+
*! Error message.
+
*! @elem array backtrace
+
*! Backtrace as returned by @[backtrace()] from where
+
*! the error occurred.
+
*! @endarray
+
*!
+
*! @note
+
*! The error message is always terminated with a newline.
+
*!
+
*! @seealso
+
*! @[backtrace()]
+
*/
void f_error_index(INT32 args) { INT_TYPE ind; get_all_args("error->`[]",args,"%i",&ind); switch(ind) { case 0: pop_n_elems(args); ref_push_string(GENERIC_ERROR_THIS->desc);
pike.git/src/error.c:559:
pop_n_elems(args); ref_push_array(GENERIC_ERROR_THIS->backtrace); break; default: index_error("error->`[]", Pike_sp-args, args, NULL, Pike_sp-args, "Index %d is out of range 0 - 1.\n", ind); break; } }
-
+
/*! @decl string describe()
+
*!
+
*! Make a readable error-message.
+
*!
+
*! @note
+
*! Uses @[describe_backtrace()] to generate the message.
+
*/
void f_error_describe(INT32 args) { pop_n_elems(args); ref_push_object(Pike_fp->current_object); APPLY_MASTER("describe_backtrace",1); }
-
+
/*! @decl array backtrace()
+
*!
+
*! Get the backtrace from where the error occurred.
+
*!
+
*! @seealso
+
*! @[predef::backtrace()]
+
*/
void f_error_backtrace(INT32 args) { pop_n_elems(args); ref_push_array(GENERIC_ERROR_THIS->backtrace); }
-
+
/*! @endclass
+
*/
+
#ifdef ERROR_DEBUG #define DWERROR(X) fprintf X #else /* !ERROR_DEBUG */ #define DWERROR(X) #endif /* ERROR_DEBUG */ #define INIT_ERROR(FEL)\ va_list foo; \ struct object *o; \ va_start(foo,desc); \