diff --git a/.gitattributes b/.gitattributes index fad50e9666c2f3db2eea0c112c33511ed565fd90..4d94e4be5d5a33f01bb2935c0b1368251e6dcec3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -98,6 +98,7 @@ testfont binary /lib/modules/Debug.pmod/Subject.pike foreign_ident /lib/modules/Debug.pmod/module.pmod foreign_ident /lib/modules/Debug.pmod/werror.pmod foreign_ident +/lib/modules/Error.pmod foreign_ident /lib/modules/Filesystem.pmod/Tar.pmod foreign_ident /lib/modules/Float.pmod foreign_ident /lib/modules/GLU.pmod foreign_ident diff --git a/lib/modules/Error.pmod b/lib/modules/Error.pmod new file mode 100644 index 0000000000000000000000000000000000000000..acf9fc89e01beec2e87f519984a755b19f35ee12 --- /dev/null +++ b/lib/modules/Error.pmod @@ -0,0 +1,32 @@ +#pike __REAL_VERSION__ + +// $Id: Error.pmod,v 1.1 2004/04/18 02:19:38 mast Exp $ + +//! @class Generic +//! +//! Class for exception objects for errors of unspecified type. +//! +//! @note +//! For historical reasons, erro + +//! @endclass + +constant Generic = __builtin.GenericError; + +constant Index = __builtin.IndexError; + +constant BadArgument = __builtin.BadArgumentError; + +constant Math = __builtin.MathError; + +constant Resource = __builtin.ResourceError; + +constant Permission = __builtin.PermissionError; + +constant Cpp = __builtin.CppError; + +constant Compilation = __builtin.CompilationError; + +constant MasterLoad = __builtin.MasterLoadError; + +constant ModuleLoad = __builtin.ModuleLoadError; diff --git a/src/dynamic_load.c b/src/dynamic_load.c index 31c7a6cd22394847e72d5bd9ecacc1ccc1ed0e3f..3998de3ec5cba38afd0ef38122ee592d7ade2572 100644 --- a/src/dynamic_load.c +++ b/src/dynamic_load.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: dynamic_load.c,v 1.82 2004/04/15 13:21:25 grubba Exp $ +|| $Id: dynamic_load.c,v 1.83 2004/04/18 02:19:38 mast Exp $ */ #ifdef TESTING @@ -24,7 +24,7 @@ # include "lex.h" # include "object.h" -RCSID("$Id: dynamic_load.c,v 1.82 2004/04/15 13:21:25 grubba Exp $"); +RCSID("$Id: dynamic_load.c,v 1.83 2004/04/18 02:19:38 mast Exp $"); #else /* TESTING */ @@ -463,9 +463,9 @@ void f_load_module(INT32 args) if(!module) { - struct object *err_obj = low_clone (dlopen_error_program); -#define DLERR_STRUCT(OBJ) \ - ((struct dlopen_error_struct *) (err_obj->storage + dlopen_error_offset)) + struct object *err_obj = low_clone (module_load_error_program); +#define LOADERR_STRUCT(OBJ) \ + ((struct module_load_error_struct *) (err_obj->storage + module_load_error_offset)) const char *err = dlerror(); if (err) { @@ -477,8 +477,8 @@ void f_load_module(INT32 args) else push_constant_text ("Unknown reason"); - add_ref (DLERR_STRUCT (err_obj)->path = Pike_sp[-args - 1].u.string); - add_ref (DLERR_STRUCT (err_obj)->dlerror = Pike_sp[-1].u.string); + add_ref (LOADERR_STRUCT (err_obj)->path = Pike_sp[-args - 1].u.string); + add_ref (LOADERR_STRUCT (err_obj)->reason = Pike_sp[-1].u.string); if (Pike_sp[-args].u.string->len < 1024) { throw_error_object (err_obj, "load_module", Pike_sp - args - 1, args, diff --git a/src/error.c b/src/error.c index 8f863f7a22c40a9cd6458b0c23d544ea5f8a91d0..1e830601fca468cc9f294e7ee1e9deef47f0565b 100644 --- a/src/error.c +++ b/src/error.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: error.c,v 1.120 2004/02/09 18:49:16 mast Exp $ +|| $Id: error.c,v 1.121 2004/04/18 02:19:38 mast Exp $ */ #define NO_PIKE_SHORTHAND @@ -23,7 +23,7 @@ #include "threads.h" #include "gc.h" -RCSID("$Id: error.c,v 1.120 2004/02/09 18:49:16 mast Exp $"); +RCSID("$Id: error.c,v 1.121 2004/04/18 02:19:38 mast Exp $"); #undef ATTRIBUTE #define ATTRIBUTE(X) @@ -607,6 +607,7 @@ static void f_error__sprintf(INT32 args) push_undefined(); return; } + push_constant_text ("Error."); push_svalue(&PROG_FROM_INT(p, i)->constants[id->func.offset].sval); push_constant_text("(%O)"); if(GENERIC_ERROR_THIS->error_message) @@ -614,7 +615,7 @@ static void f_error__sprintf(INT32 args) else push_int(0); f_sprintf(2); - f_add(2); + f_add(3); } /*! @decl void create(string message) @@ -782,13 +783,13 @@ PMOD_EXPORT DECLSPEC(noreturn) void bad_arg_error( struct svalue *got_value, const char *desc, ...) ATTRIBUTE((noreturn,format (printf, 7, 8))) { - INIT_ERROR(bad_arg); - ERROR_COPY(bad_arg, which_argument); + INIT_ERROR(bad_argument); + ERROR_COPY(bad_argument, which_argument); if (expected_type) - ERROR_STRUCT(bad_arg,o)->expected_type=make_shared_string(expected_type); + ERROR_STRUCT(bad_argument,o)->expected_type=make_shared_string(expected_type); else - ERROR_STRUCT(bad_arg,o)->expected_type = NULL; - ERROR_COPY_SVALUE(bad_arg, got_value); + ERROR_STRUCT(bad_argument,o)->expected_type = NULL; + ERROR_COPY_SVALUE(bad_argument, got_value); DWERROR((stderr, "%s():Bad arg %d (expected %s)\n", func, which_arg, expected_type)); ERROR_DONE(generic); diff --git a/src/errors.h b/src/errors.h index 483c14bac504c3a7c9284eda779fdccfb1ddbb6f..c2467b2752e44a240d165ede2da22d593f8888b5 100644 --- a/src/errors.h +++ b/src/errors.h @@ -2,11 +2,11 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: errors.h,v 1.25 2004/03/22 17:42:07 mast Exp $ +|| $Id: errors.h,v 1.26 2004/04/18 02:19:38 mast Exp $ */ #ifdef ERR_DECLARE -#define DECLARE_ERROR(NAME, INHERIT, DECL) \ +#define DECLARE_ERROR(NAME, SCNAME, INHERIT, DECL) \ PMOD_EXPORT struct program *PIKE_CONCAT(NAME,_error_program); \ ptrdiff_t PIKE_CONCAT(NAME,_error_offset); @@ -14,7 +14,7 @@ ptrdiff_t PIKE_CONCAT(NAME,_error_offset); #endif #ifdef ERR_EXT_DECLARE -#define DECLARE_ERROR(NAME, INHERIT, DECL) \ +#define DECLARE_ERROR(NAME, SCNAME, INHERIT, DECL) \ PMOD_EXPORT extern struct program *PIKE_CONCAT(NAME,_error_program); \ extern ptrdiff_t PIKE_CONCAT(NAME,_error_offset); \ struct PIKE_CONCAT(NAME,_error_struct) { \ @@ -29,18 +29,18 @@ struct PIKE_CONCAT(NAME,_error_struct) { \ #endif /* ERR_EXT_DECLARE */ #ifdef ERR_SETUP -#define DECLARE_ERROR(NAME, INHERIT, DECL) do{ \ +#define DECLARE_ERROR(NAME, SCNAME, INHERIT, DECL) do{\ ptrdiff_t current_offset=0; \ struct PIKE_CONCAT(NAME,_error_struct) foo; \ start_new_program(); \ INHERIT \ current_offset = PIKE_CONCAT(NAME,_error_offset) = \ ADD_STORAGE(struct PIKE_CONCAT(NAME,_error_struct));\ - add_string_constant("error_type",#NAME "_error",0); \ + add_string_constant("error_type", #SCNAME, 0); \ add_integer_constant("is_" #NAME "_error",1,0); \ DECL \ PIKE_CONCAT(NAME,_error_program)=end_program(); \ - add_program_constant( #NAME "_error",PIKE_CONCAT(NAME,_error_program),0); \ + add_program_constant( #SCNAME "Error",PIKE_CONCAT(NAME,_error_program),0); \ }while(0); #define ERR_VAR(TYPE,CTYPE,RUNTYPE,NAME2) \ @@ -58,7 +58,7 @@ struct PIKE_CONCAT(NAME,_error_struct) { \ #endif #ifdef ERR_CLEANUP -#define DECLARE_ERROR(NAME, INHERIT, DECL) \ +#define DECLARE_ERROR(NAME, SCNAME, INHERIT, DECL) \ if(PIKE_CONCAT(NAME,_error_program)) {\ free_program(PIKE_CONCAT(NAME,_error_program)); \ PIKE_CONCAT(NAME,_error_program)=0;\ @@ -78,7 +78,7 @@ struct PIKE_CONCAT(NAME,_error_struct) { \ #define ERR_FUNC(NAME,FUNC,TYPE,FLAGS) #endif -DECLARE_ERROR(generic, EMPTY , +DECLARE_ERROR(generic, Generic, EMPTY , ERR_VAR(struct pike_string *,string,PIKE_T_STRING,error_message) ERR_VAR(struct array *,array,PIKE_T_ARRAY,error_backtrace) ERR_FUNC("cast",f_error_cast,tFunc(tString,tMixed),0) @@ -92,45 +92,45 @@ DECLARE_ERROR(generic, EMPTY , #define GENERIC_ERROR_THIS ((struct generic_error_struct *)CURRENT_STORAGE) -DECLARE_ERROR(index, +DECLARE_ERROR(index, Index, ERR_INHERIT(generic), ERR_VAR(struct svalue, mixed, PIKE_T_MIXED, value) ERR_VAR(struct svalue, mixed, PIKE_T_MIXED, index) ) -DECLARE_ERROR(bad_arg, +DECLARE_ERROR(bad_argument, BadArgument, ERR_INHERIT(generic), ERR_VAR(INT_TYPE, int, PIKE_T_INT, which_argument) ERR_VAR(struct pike_string *,string,PIKE_T_STRING,expected_type) ERR_VAR(struct svalue, mixed, PIKE_T_MIXED, got_value) ) -DECLARE_ERROR(math, +DECLARE_ERROR(math, Math, ERR_INHERIT(generic), ERR_VAR(struct svalue, mixed, PIKE_T_MIXED, number) ) -DECLARE_ERROR(resource, +DECLARE_ERROR(resource, Resource, ERR_INHERIT(generic), ERR_VAR(struct pike_string *,string,PIKE_T_STRING,resource_type) ERR_VAR(INT_TYPE, int, PIKE_T_INT, howmuch) ) -DECLARE_ERROR(permission, +DECLARE_ERROR(permission, Permission, ERR_INHERIT(generic), ERR_VAR(struct pike_string *,string,PIKE_T_STRING,permission_type) ) -DECLARE_ERROR(cpp, ERR_INHERIT(generic), EMPTY) +DECLARE_ERROR(cpp, Cpp, ERR_INHERIT(generic), EMPTY) -DECLARE_ERROR(compilation, ERR_INHERIT(generic), EMPTY) +DECLARE_ERROR(compilation, Compilation, ERR_INHERIT(generic), EMPTY) -DECLARE_ERROR(master_load, ERR_INHERIT (generic), EMPTY) +DECLARE_ERROR(master_load, MasterLoad, ERR_INHERIT (generic), EMPTY) -DECLARE_ERROR (dlopen, +DECLARE_ERROR (module_load, ModuleLoad, ERR_INHERIT (generic), ERR_VAR (struct pike_string *, string, PIKE_T_STRING, path) - ERR_VAR (struct pike_string *, string, PIKE_T_STRING, dlerror) + ERR_VAR (struct pike_string *, string, PIKE_T_STRING, reason) ) #undef DECLARE_ERROR