[erlang-questions] error handling in docbuilder

Kenneth Lundin kenneth.lundin@REDACTED
Wed Mar 19 14:48:37 CET 2008


Hi,

This is very old code with problems that we might not detect from the
use cases we have. I will improve this in one of the next releases.

/Kenneth

On 3/19/08, Ulf Wiger (TN/EAB) <ulf.wiger@REDACTED> wrote:
>
> I came across the following code in docb_transform.erl (docbuilder):
>
> file(File0, RawOpts) ->
>     File = filename:rootname(File0), % without extension
>     Ext = case filename:extension(File0) of
>               ".xml" -> ".xml";
>               ".sgml" -> ".sgml";
>               "" ->
>                   %% If the file is given without extension, we try to
>                   %% infer if the source file is XML or SGML.
>                   %% SGML is supported *internally within OTP* for
>                   %% backwards compatibility reasons.
>                   case filelib:is_regular(File++".xml") of
>                       true -> ".xml";
>                       false -> ".sgml"
>                   end;
>               _Ext0 -> % this is probably an error...
>                   ".xml"
>           end,
>
> The catch-all clause that takes whatever unknown extension
> given by the caller and changes it to ".xml" seems a bit
> too "flexible" for my taste. If the caller provides an
> unsupported extension, wouldn't it be better to return
> an error?
>
> Another gripe, while I'm at it, is that docb_util.erl
> uses e.g. catch Mod:top(), if a {html_mod, Mod} option
> has been specified, and silently ignores {'EXIT',undef}.
>
> But if the 'undef' is due to the fact that Mod cannot
> be found, this ought to be reported as an error.
> While all functions in the callback module are optional,
> clearly if a callback module has been specified, it must
> be considered an error if the module itself cannot be
> found.
>
> BR,
> Ulf W
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list