Branch: Tag:

2012-06-21

2012-06-21 18:15:40 by Martin Stjernholm <mast@lysator.liu.se>

Cleaned up error reporting in the image caches.

Draw callbacks now throw rxml errors, and they get reported in a decent way
in the image cache filesystem as well. This should finally avoid noisy pike
backtraces for invalid cimg images etc.

Rev: server/base_server/roxen.pike:1.1118
Rev: server/etc/modules/LazyImage.pmod/module.pmod:1.27
Rev: server/modules/graphics/cimg.pike:1.92
Rev: server/modules/graphics/gbutton.pike:1.127
Rev: server/modules/graphics/graphic_text.pike:1.316

6:   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.1117 2012/06/09 14:15:07 mast Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.1118 2012/06/21 18:15:40 mast Exp $";      //! @appears roxen   //!
4256:    if (mapping res = draw( na, id ))    return res;    })) { -  // File not found. -  -  if(arrayp(err) && sizeof(err) && stringp(err[0])) -  { -  if (sscanf(err[0], "Requesting unknown key %s\n", -  string message) == 1) -  { -  report_debug("Requesting unknown key %s %O from %O\n", -  message, -  id->not_query, -  (sizeof(id->referer)?id->referer[0]:"unknown page")); +  if (objectp (err) && err->is_RXML_Backtrace && !RXML_CONTEXT) { +  // If we get an rxml error and there's no rxml context then +  // we're called from a direct request to the image cache. +  // The error ought to have been reported in the page that +  // generated the link to the image cache, but since it's too +  // late for that now, we just log it as a (brief) server +  // error with the referring page. +  string errmsg = "Error in " + name + " image generation: " + +  err->msg; +  if (sizeof (id->referer)) +  errmsg += " Referrer: " + id->referer[0]; +  report_error (errmsg + "\n");    return 0;    } -  if (sscanf(err[0], "Failed to load specified image [\"%s\"]\n", -  string message) == 1) -  { -  report_debug("Failed to load specified image %O from %O - referrer %O\n", -  message, -  id->not_query, -  (sizeof(id->referer)?id->referer[0]:"unknown page")); -  return 0; +  throw (err);    } -  } -  report_debug("Error in draw: %s\n", describe_backtrace(err)); -  return 0; -  } +     if( !(res = restore( na,id )) ) {    error("Draw callback %O did not generate any data.\n"    "na: %O\n"
4491:    //! may take any arguments you want, depending on the first argument    //! you give the <ref>store()</ref> method, but its final argument    //! will be the RequestID object. +  //! +  //! @note +  //! Use @[RXML.run_error] or @[RXML.parse_error] within the draw +  //! function to throw user level drawing errors, e.g. invalid or +  //! missing images or argument errors. If it's called within a +  //! graphics tag then the error is thrown directly and reported +  //! properly by the rxml evaluator. If it's called later, i.e. in a +  //! direct request to the image cache, then it is catched by the +  //! @[ImageCache] functions and reported in as good way as possible, +  //! i.e. currently briefly in the debug log.    {    name = id;    draw_function = draw_func;