[reportlab-users] format error? Boy is that confusing!

Robin Becker robin at reportlab.com
Wed May 6 06:53:41 EDT 2015

On 05/05/2015 22:44, Glenn Linderman wrote:
> What makes this stack trace so unintelligible, is that it says "format not
> resolved" and then shows a relative URL.  It makes it seem like it is trying to
> interpret the URL as a format code (of some unknown sort), and my thoughts
> immediately went to the possibility of having omitted the format code parameter,
> and supplied the URL as the wrong parameter, somewhere along the line, and of
> course doc.build has so many deferred operations that there is little clue as to
> where in the document this actually takes place.
here format appears to refer to a .fmt attribute in the Destination object. 
Destinations are created when a reference is made to them, but need to be filled 
in by a later definition so that a click on the tag / link or whatever can jump 
to the appropriate place. Like <a> in html they are both a link and a target. I 
assume that the document never saw '../../hc/foo.png' as a target and so the 
definition of the destination never got carried out.

> It would be extremely more useful to for the message to say something like "URL
> scheme missing" or "unknown scheme" using the terminology for URLs.  If, at the
> point of error generation, it truly is not known, and cannot easily be known,
> whether this is a "format" (whatever that means) or a URL (which is missing its
> scheme), then having the message say "format unresolved or URL scheme missing"
> would certain be an improvement in clarity at little expense of reworking the
> code (just changing a message).
Since the destination definition never got seen we don't actually know what was 
intended. I suppose a better error message might be "target of destination with 
name '../../hc/foo.png' was not defined", however, that doesn't cover the 
semantics of the case where you just forgot to put in http and the link was to 
an external. So perhaps we can use

"missing URL scheme or undefined destination target for xxx"

> Personally, I have no clue what other cases would cause the message, that would
> make "format not resolved" a useful message, but I'm making the assumption that
> such a case exists.
> Here's an abbreviated stack trace:
>      if f is None: raise ValueError("format not resolved %s" % self.name)
> ValueError: format not resolved ../../hc/foo.png
>   Errorlevel 1 from bixutls.py.  Exiting.
Robin Becker

More information about the reportlab-users mailing list