pike.git / src / error.c

version» Context lines:

pike.git/src/error.c:15:   #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.86 2002/08/15 14:49:21 marcus Exp $"); + RCSID("$Id: error.c,v 1.87 2002/08/15 17:43:25 marcus Exp $");      #undef ATTRIBUTE   #define ATTRIBUTE(X)      PMOD_EXPORT const char msg_fatal_error[] =    "%s:%d: Fatal error:\n";   #ifdef PIKE_DEBUG   PMOD_EXPORT const char msg_unsetjmp_nosync_1[] =    "UNSETJMP out of sync! (last SETJMP at %s)!\n";   PMOD_EXPORT const char msg_unsetjmp_nosync_2[] =
pike.git/src/error.c:405:    *! The only supported type to cast to is @tt{"array"@}, which    *! generates and old-style error.    */   static 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); +  if(GENERIC_ERROR_THIS->desc)    ref_push_string(GENERIC_ERROR_THIS->desc); -  +  else +  push_int(0); +  if(GENERIC_ERROR_THIS->backtrace)    ref_push_array(GENERIC_ERROR_THIS->backtrace); -  +  else +  push_int(0);    f_aggregate(2);    }else{    SIMPLE_BAD_ARG_ERROR("error->cast", 1, "the value \"array\"");    }   }      /*! @decl array|string `[](int(0..1) index)    *!    *! Index operator.    *!
pike.git/src/error.c:441:    */   static void f_error_index(INT32 args)   {    INT_TYPE ind;    get_all_args("error->`[]",args,"%i",&ind);       switch(ind)    {    case 0:    pop_n_elems(args); +  if(GENERIC_ERROR_THIS->desc)    ref_push_string(GENERIC_ERROR_THIS->desc); -  +  else +  push_int(0);    break;    case 1:    pop_n_elems(args); -  +  if(GENERIC_ERROR_THIS->backtrace)    ref_push_array(GENERIC_ERROR_THIS->backtrace); -  +  else +  push_int(0);    break;    default:    index_error("error->`[]", Pike_sp-args, args, NULL, Pike_sp-args,    "Index %"PRINTPIKEINT"d is out of range 0 - 1.\n", ind);    break;    }   }      /*! @decl string describe()    *!
pike.git/src/error.c:478:   /*! @decl array backtrace()    *!    *! Get the backtrace from where the error occurred.    *!    *! @seealso    *! @[predef::backtrace()]    */   static void f_error_backtrace(INT32 args)   {    pop_n_elems(args); +  if(GENERIC_ERROR_THIS->backtrace)    ref_push_array(GENERIC_ERROR_THIS->backtrace); -  +  else +  push_int(0);   }      /*! @decl string _sprintf()    */   static void f_error__sprintf(INT32 args)   {    struct program *p = Pike_fp->current_object->prog;    int i = find_identifier("error_type", p);    struct identifier *id = ID_FROM_INT(p, i);    pop_n_elems(args);    push_svalue(&PROG_FROM_INT(p, i)->constants[id->func.offset].sval);    push_constant_text("(%O)"); -  +  if(GENERIC_ERROR_THIS->desc)    ref_push_string(GENERIC_ERROR_THIS->desc); -  +  else +  push_int(0);    f_sprintf(2);    f_add(2);   }    -  + /*! @decl void create(string message) +  */ + static void f_error_create(INT32 args) + { +  struct pike_string *msg; +  get_all_args("create", args, "%W", &msg); +  do_free_string(GENERIC_ERROR_THIS->desc); +  copy_shared_string(GENERIC_ERROR_THIS->desc, msg); +  f_backtrace(0); +  push_int (0); +  push_int (Pike_sp[-2].u.array->size-2); +  o_range (); +  assign_to_short_svalue ((union anything *)&GENERIC_ERROR_THIS->backtrace, +  PIKE_T_ARRAY, Pike_sp-1); +  pop_n_elems(args+1); + } +    /*! @endclass    */      #ifdef ERROR_DEBUG   #define DWERROR(X) fprintf X   #else /* !ERROR_DEBUG */   #define DWERROR(X)   #endif /* ERROR_DEBUG */      #define INIT_ERROR(FEL)\