From 667ec2942c41f9387a92e5ebfbaba750c663b7c0 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm <mast@lysator.liu.se> Date: Tue, 22 Jul 2003 01:41:34 +0200 Subject: [PATCH] Do not silently suppress errors catched in main when there's no master; call_handle_error copes with that now. Added a special error type for the load master error so that it can be reported nicely in main. Rev: src/errors.h:1.23 Rev: src/main.c:1.178 Rev: src/object.c:1.241 --- src/errors.h | 4 +++- src/main.c | 22 +++++++++++++++++++--- src/object.c | 7 ++++--- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/errors.h b/src/errors.h index 1b656ba1b8..7524e7f0b7 100644 --- a/src/errors.h +++ b/src/errors.h @@ -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: errors.h,v 1.22 2002/10/11 01:39:31 nilsson Exp $ +|| $Id: errors.h,v 1.23 2003/07/21 23:41:34 mast Exp $ */ #ifdef ERR_DECLARE @@ -124,6 +124,8 @@ DECLARE_ERROR(cpp, ERR_INHERIT(generic), EMPTY) DECLARE_ERROR(compilation, ERR_INHERIT(generic), EMPTY) +DECLARE_ERROR(master_load, ERR_INHERIT (generic), EMPTY) + #undef DECLARE_ERROR #undef ERR_INHERIT #undef ERR_VAR diff --git a/src/main.c b/src/main.c index f027788f35..6c752fef5a 100644 --- a/src/main.c +++ b/src/main.c @@ -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: main.c,v 1.177 2003/06/30 17:06:09 mast Exp $ +|| $Id: main.c,v 1.178 2003/07/21 23:41:34 mast Exp $ */ #include "global.h" -RCSID("$Id: main.c,v 1.177 2003/06/30 17:06:09 mast Exp $"); +RCSID("$Id: main.c,v 1.178 2003/07/21 23:41:34 mast Exp $"); #include "fdlib.h" #include "backend.h" #include "module.h" @@ -722,7 +722,23 @@ int dbm_main(int argc, char **argv) { num=throw_value.u.integer; }else{ - if (get_master()) call_handle_error(); + if (throw_value.type == T_OBJECT && + throw_value.u.object->prog == master_load_error_program && + !get_master()) { + /* Report this specific error in a nice way. Since there's no + * master it'd be reported with a raw error dump otherwise. */ + struct generic_error_struct *err; + *(Pike_sp++) = throw_value; + dmalloc_touch_svalue(Pike_sp-1); + throw_value.type=T_INT; + err = (struct generic_error_struct *) + get_storage (Pike_sp[-1].u.object, generic_error_program); + push_string (err->desc); + f_werror (1); + pop_stack(); + } + else + call_handle_error(); num=10; } }else{ diff --git a/src/object.c b/src/object.c index 57bb594b37..77171e0d74 100644 --- a/src/object.c +++ b/src/object.c @@ -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: object.c,v 1.240 2003/07/21 16:23:58 grubba Exp $ +|| $Id: object.c,v 1.241 2003/07/21 23:41:34 mast Exp $ */ #include "global.h" -RCSID("$Id: object.c,v 1.240 2003/07/21 16:23:58 grubba Exp $"); +RCSID("$Id: object.c,v 1.241 2003/07/21 23:41:34 mast Exp $"); #include "object.h" #include "dynamic_buffer.h" #include "interpret.h" @@ -606,7 +606,8 @@ PMOD_EXPORT struct object *get_master(void) sp--; dmalloc_touch_svalue(sp); }else{ - Pike_error("Couldn't load master program. (%s)\n",master_file); + throw_error_object (low_clone (master_load_error_program), 0, 0, 0, + "Couldn't load master program from %s.\n", master_file); } } -- GitLab