Branch: Tag:

2008-05-30

2008-05-30 17:01:49 by Martin Stjernholm <mast@lysator.liu.se>

Some fixes in the handling of compiler exceptions so that we get rid of the
backtrace clutter.

Rev: lib/master.pike.in:1.428
Rev: lib/modules/Tools.pmod/Hilfe.pmod:1.152

6:   // Pike is distributed under GPL, LGPL and MPL. See the file COPYING   // for more information.   // - // $Id: master.pike.in,v 1.427 2008/05/29 18:12:12 grubba Exp $ + // $Id: master.pike.in,v 1.428 2008/05/30 17:01:48 mast Exp $      #pike __REAL_VERSION__   //#pragma strict_types
1108:    return ({ fname + ".o" });   }    - static class CompileCallbackError (string error_message, array error_backtrace) + static class CompileCallbackError   { -  +  inherit _static_modules.Builtin.GenericError;    constant is_generic_error = 1;    constant is_compile_callback_error = 1; -  +  constant is_cpp_or_compilation_error = 1;   }      static void compile_cb_error (string msg, mixed ... args)
3231:    argv = tmp->get_args(argv,1);       program prog; +  mixed compile_err = catch {;    if(Version(compat_major,compat_minor) <= Version(7,4))    prog = compile_string(    "mixed create(int argc, array(string) argv,array(string) env){"+
3247:    "mapping(string:string) env){"+    code+";}");    } +  };    -  +  if (compile_err && compile_err->is_cpp_or_compilation_error) { +  // Don't clutter the output with the backtrace for +  // compilation errors. +  werror (describe_error (compile_err)); +  exit (20); +  } +  else throw (compile_err); +    #if constant(_debug)    if(debug) _debug(debug);   #endif
3378:    if( !master_read_file(fn) )    exit(1, "File %O is not readable. %s.\n",    fn, strerror(errno())); +  if (objectp (err) && err->is_cpp_or_compilation_error) +  exit(1, "Pike: Failed to compile script.\n"); +  else    exit(1, "Pike: Failed to compile script:\n" -  "%s\n", stringp(err[0])?err[0]:describe_backtrace(err)); +  "%s", describe_backtrace(err));    }       // Don't list the program with its real path in the programs
3547:   //! this function returns zero.   int compile_exception (array|object trace)   { -  if (objectp (trace) && -  ( ([object]trace)->is_cpp_error || -  ([object]trace)->is_compilation_error)) -  // Errors thrown directly by cpp() and compile() are normally not -  // interesting; they've already been reported to compile_error. -  return 1; -  if (objectp (trace) && ([object] trace)->is_compile_callback_error) -  // Errors thrown by a compile callback that we should report as a -  // normal compile error, so let the caller do just that. +  if (objectp (trace) && ([object]trace)->is_cpp_or_compilation_error) +  // Errors thrown by cpp(), compile() or a compile callback should +  // be reported as a normal compile error, so let the caller do +  // just that.    return 0;    if (mixed val = get_inhibit_compile_errors()) {    if (objectp(val) && ([object]val)->compile_exception)