Stan errors should be enums, not external const values.



11 years ago
11 years ago


(Reporter: Robert Relyea, Unassigned)


Firefox Tracking Flags

(Not tracked)




11 years ago
Currently Stan errors are define as such:

const NSSError ERROR_VALUE = n;

in nss/base/errorval.c

The idea, I believe, was that error values could be defined in different modules
and 'automatically' picked up when the module was included.

This definition, whoever, makes certain processing of the errors difficult when trying to deal with the whole list, or at least most of the list. Switch statements, for instance won't work.

As part of fixing this, we should also change CERT_MapStanError() to use a switch statement instead of if/else if/ statements.

Readers of the Stan code will note that there is not even a single header
file that declares all those "extern const NSSError" variables.  

Instead, each module that uses any of those NSSErrors is expected to have
its own "extern const NSSError" declaration for each and every NSSError 
code that it uses.

IIRC, the rationale for that approach was ease of documentation.  It would
be easy to find out what error codes were used (that is, "thrown") by an
NSS source file by simply grepping the source file to find the 
"extern const NSSError" declarations in the source file.  

The supposed value of that ease of documentation seems to be much less than
the value of maintainability of the source code which has been lost, IMO.
You need to log in before you can comment on or make changes to this bug.