next up previous contents index
Next: Bibliography Up: 12. Spectral Envelope Library Previous: 12.2 Programs User Manual

Subsections

12.3 Library Functions User Manual

12.3.1 Error Handling

Error handling in a function library is always a difficult point. Ideally, all errors will be detected and handled in the library, if possible. If not, they will be passed to the calling program. In any case, a library must never call exit() or abort() and thus stop the process if any unexpected situation occurs, because it is up to the caller to decide what to do in such cases, not up to the library. Who knows, maybe the calling program has a method to handle the error and can recover from it. What's more, detecting the cause of an error is made more difficult, when suddenly the program stops in some low level library function, without knowing when and by whom it was called. (Example: Compare the usefulness of the error message ``read error'' with ``error reading file header''.)

In an environment without exception handling such as ANSI-C, however, this behaviour of passing on error conditions requires some discipline on the side of the user. It is mandatory that all return codes of library functions are checked for seOK, since there may have been a fatal error. Because this may cause problems to unexperience programmers and is not adequate for a quick and dirty test program, there is also an option to have the library abort on error. (This is the default behaviour of the library, in fact.)

The error behaviour of the library is controlled by seSetErrorBehaviour which can take a member of the enum seErrorBehaviour. If the bit seEbAbort is set, the library aborts (and core dumps) on any error. If the seEbPrint is set, an error message is printed on the console (standard error). If the seEbLog is set, a detailed error message is also written to a log file, which can be set with seSetErrorLogFile, if the default specenv.log is not appropriate. Various predefined combinations of the error behaviour flags exist: seEbFull, the default, has all three flags set; seEbNorm is the normal behaviour for well-behaved programs, and means: continue on error, but print and log the error message (seEbLog | seEbPrint).

12.3.2 Message Handling

12.3.3 Parameter Passing

parameters are gathered in structures which also hold input/output data

12.3.4 Function Reference


next up previous contents index
Next: Bibliography Up: 12. Spectral Envelope Library Previous: 12.2 Programs User Manual
Diemo Schwarz
1998-09-07