home *** CD-ROM | disk | FTP | other *** search
- .Na "dberrhandle"
- .Aa
- .Fu
- Install a user function to handle \*L errors.
- .Ih "error handler, installing"
- .Ih "\*L errors"
- .Ih "errors, \*L"
- .Sy
- .Sf "int (*dberrhandle(handler))()"
- .Sp "int" "(*handler)()"
- .Co
- .Bl
- \f2dberrhandle()\f1 installs an error-handler function that you supply.
- When a \*L error occurs, \*L will call this
- error handler immediately.
- You must install an error handler
- in order to handle \*L errors properly.
- .Bl
- The user-supplied error handler will completely determine the response
- of \*L to any error that occurs.
- It must tell \*L whether to:
- .in +5n
- .Bl *
- abort the program,
- .Bl *
- return an error code, \f2or\f1
- .Bl *
- keep trying (in the case of a timeout error).
- .in -5n
- .Bl
- If the user does not supply an error handler (or passes a NULL pointer
- to \f2dberrhandle()\fP), \*L will exhibit its default error-handling
- behavior: It will abort the program if the error
- has made the affected DBPROCESS unusable (the user can call \f2DBDEAD()\fP
- to determine whether or not a DBPROCESS has become unusable). If the error
- has not made the DBPROCESS unusable, \*L will simply return an error code
- to its caller.
- .Bl
- You can de-install an existing error handler by calling \f2dberrhandle()\f1 with a
- NULL parameter.
- You can also, at any time, install a new error handler.
- The new handler will automatically replace any existing handler.
- .Bl
- If the program refers to error severity values, its source file must include the header
- file \f2syberror.h\f1.
- .Bl
- See the \f2errors\f1 manual page for a list of \*L errors.
- .Bl
- Another routine, \f2dbmsghandle()\f1, installs a message handler that \*L calls
- in response to \*S error messages.
- If the application provokes messages from \*L and \*S simultaneously,
- \*L calls the \*S message handler before it calls the \*L error handler.
- .Bl
- The \*L error value SYBESMSG is always generated in response to a \*S message.
- If you have installed a \*S message handler, you may want to write your \*L error handler
- so as to suppress the printing of any SYBESMSG error, to avoid notifying
- the user about the same error twice.
- .Bz
- .Pa
- .Pi handler
- A pointer to the user function that will be called whenever
- \*L determines that an error has occurred. \*L calls this function
- with six parameters:
- .sp
- .in +10n
- .ta +10n
- .ti -10n
- \f2dbproc\f1 The affected DBPROCESS. If there is no DBPROCESS associated with this error,
- this parameter will be NULL.
- .sp 0.5v
- .ti -10n
- \f2severity\f1 The severity of the error (datatype \f2int\f1).
- Error severities are defined in \f2syberror.h\f1.
- .sp 0.5v
- .ti -10n
- \f2dberr\f1 The identifying number of the error (datatype \f2int\f1).
- Error numbers are defined in \f2sybdb.h\f1.
- .sp 0.5v
- .ti -10n
- \f2oserr\f1 The operating-system-specific error number that describes the cause
- of the error (datatype \f2int\f1).
- If there is no relevant operating-system error, the value of this parameter will be DBNOERR.
- .sp 0.5v
- .mc |
- .ti -10n
- \f2dberrstr\f1 A printable description of \f2dberr\f1 (datatype \f2char *\f1).
- .sp 0.5v
- .ti -10n
- \f2oserrstr\f1 A printable description of \f2oserr\f1 (datatype \f2char *\f1).
- .sp
- .mc
- .in -10n
- The error handler must return one of the following three values, directing \*L
- to perform particular actions:
- .sp
- .in +17n
- .ta +17n
- .ti -17n
- INT_EXIT Print an error message and abort the program.
- \*L will also return
- an error indication to the operating system.
- (Note to UNIX programmers: \*L will not leave a core file.)
- .sp 0.5v
- .ti -17n
- INT_CANCEL Return FAIL from the \*L routine that caused the error,
- and set the global \*L error number.
- .sp 0.5v
- .ti -17n
- INT_CONTINUE Continue to wait for one additional timeout period.
- At the end of that period, call the error handler again.
- This return value is meaningful only for timeout
- errors (SYBETIME). In any other case, this value
- will be considered an error, and will be treated
- as an INT_EXIT.
- .sp
- .in -17n
- If the error handler returns any value besides these three, the program will abort.
- .sp
- The following example shows a typical error handler routine:
- .ta +4n +4n +4n +4n +4n +4n
- .SD
- .mc |
- .so dberrhandle.ex
- .mc
- .ED
- .in -.375i
- .Re
- .br
- A pointer to the previously-installed error handler.
- This may be NULL.
- .Sa
- DBDEAD,
- dbmsghandle,
- errors
-