#199 closed defect (fixed)
Suggested Updates to Error Message API
| Reported by: | Owned by: | eugene | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | PSLib SDRS | Version: | unspecified |
| Severity: | normal | Keywords: | IPP-doc |
| Cc: |
Description
Would it be possible to update the psErrorMsg() function argument list to take
func and LINE arguments? At it stands, it's a little cumbersome to have
to grep on error messages to find the exact line where the error occurred,
especially if several different functions in a single file use the same error
message text.
Also, I agree with Robert Lupton's comments of late that error messages
shouldn't be on multiple lines. I don't think we always need to have the time,
date, and host name printed for all errors, which currently consumes a large
portion of space. If we could make these optional outputs triggered by some
type of flag, we could reduce some of the excess space and move back to a
single line format.
Change History (3)
comment:1 by , 22 years ago
| Summary: | Suggested Updates to Error Message API → Suggested Updates to Error Message API |
|---|
comment:2 by , 22 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Updated the SDRS along the above lines. Note in particular that the component
name for psLogMsg is specified to be file:line, as in "someFileName.c:123"
\begin{verbatim}
psErrorCode p_psError(const char *file, int lineno, psErrorCode code, bool new,
const char *fmt, ...);
#define psError(code, new, fmt, ...) psError(FILE, LINE, code, new, fmt,
VA_ARGS)
\end{verbatim}
\code{psError} is a macro definition that allows the function and line
number to be inputted to a private function, \code{p_psError}. The
\code{code} is an enumerated type which lists the possible
\textit{classes} of errors (e.g. \code{PS_ERR_IO}) that \PS{} code can
generate (see section \ref{psErrorCodes}). The \code{new} argument
takes a boolean which, if \code{TRUE} specifies that the error was set
initially at this location, and if \code{FALSE} specifies that an
error was passed to this location. Raising new error should clear the
error stack. The final required argument, \code{fmt}, is a
\code{printf}-style format that is passed to \code{psLogMsgV} with
code \code{PS_LOG_ERROR}, and component equal to the concatenation of
the file name and the line number, separated by a colon. The result
of a call to \code{psError} must be to push an error onto a stack;
this stack is cleared if \code{new} is true, or by a call to
\code{psErrorClear}.
comment:3 by , 22 years ago
| bug_group: | PSLib? → IPP-doc? |
|---|---|
| Component: | system → PSLib SDRS |
| Keywords: | IPP-doc added; PSLib removed |
| product: | PSLib → IPP-doc |

In response to the previous comments,
Doesn't psErrorMsg() use psLogMsg(), whose verbosity is controlled by psLogSetFormat()?
As to adding func and LINE, we already pretty much always have func as the
first argument, and I'd have no problem adding LINE as a second, and thus making
psErrorMsg a macro:
#define psErrorMsg(code, newError, fmt, ...) \
or whatever C99 requires for vararg macros.