[NTG-context] No error when loading a non-existent module

Hans Hagen j.hagen at freedom.nl
Thu Aug 25 08:57:19 CEST 2022


On 8/25/2022 2:19 AM, Max Chernoff via ntg-context wrote:
> Hi all,
> 
> If you load a non-existent module, ConTeXt issues a minor warning, but
> otherwise proceeds as normal:
> 
> MWE:
> 
>     \usemodule[doesnt-exist]
>     
>     \starttext
>     Hello world!
>     \stoptext
>     
> I think that this behaviour should be changed so that a fatal error is
> issued when a loaded module cannot be found. Plain TeX, LaTeX, and OpTeX
> all throw an error whenever their versions of modules cannot be found, so
> ConTeXt is the odd one out here.
> 
> There are 3 scenarios that I can think of for when you attempt to load a
> module, but it cannot be found:
> 
> 1. A module provides some new command "\somecommand"
> 
>     In this case, loading the module will quietly fail, but an undefined
>     control sequence error will be issued whenever you use
>     "\somecommand". This disguises the root problem, which is that the
>     module was never loaded, potentially confusing users.

It doesn't tell you where to look unless we parse all files.

> 2. A module changes the layout of a document
> 
>     In this case, the layout of the document would be unchanged by the
>     module. If you're looking at every document, then this would be
>     obvious; however, if you're using some batch processing system, you
>     could unknowingly send out incorrectly-styled documents quite easily.

Ah ... but texies claim to see the difference so it's an exercise!

> 3. You load a module that provides some command, then never use it
> 
>     This is the only case where the new error would break any documents.
>     However, this case should hopefully be pretty rare since it's
>     pointless to load a module then never use any of its features.

Indeed harmless.

> Making this change could potentially break some documents that currently
> work, but I think that this change is worth it, since I'd rather have
> something break loudly (throwing an error) rather than silently (producing
> a semi-corrupt document).
But ... you can already do

\enabledirectives[logs.errors=*]

or

\enabledirectives[logs.errors=missing modules]

and if needed can add that line to a local cont-loc.mkxl file so that it 
always kicks in.

However, more dangerous is when a user overloads a system macro so if 
you realy want to play safe:

\enabledirectives[overloadmode=error] % or warning

is yuour friend.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list