report_ns* NewError_ns ( environ_ns*  env,   int  number,   errseverity_ns  severity,   const char*  mesg )

Generates a new error report, with its error number being number, severity level severity, and error message mesg. The new report is returned and registered with environment env. There is no need to worry about deleting the report object created, since this will be done automatically when the error is removed with either ClearError_ns or ClearErrors_ns.

The Netica API communicates to you every error condition it detects via a report_ns registered with the environment. This function is provided as a convenience, so that you can make your own report_ns registered with the environment, which can later be recovered with GetError_ns, allowing for simpler and more consistent error handling when extending Netica API.

severity must be one of NOTHING_ERR, REPORT_ERR, NOTICE_ERR, WARNING_ERR, ERROR_ERR, XXX_ERR (for a description of these see ErrorSeverity_ns).

number is an error number of your choice, but it must be between 1 and 999, inclusive. Netica will never generate errors with these numbers on its own.

To distinguish between an error generated by this function, or internally by Netica, see ErrorCategory_ns (passing FROM_DEVELOPER_CND).

There is no need to delete the report object created, since this will be done automatically when the error is removed with either ClearError_ns or ClearErrors_ns.

Version:

In versions previous to 2.10, this function was named ReportError_ns.

See also:

ClearError_ns    (reverse operation) Removes an error report from the system
GetError_ns    Obtain the error report from the environment
ErrorMessage_ns    Retrieve the error message from the report
ErrorNumber_ns    Retrieve the error number from the report
ErrorSeverity_ns    Retrieve the severity level of the error from the report

Example:

The following function is available in NeticaEx.c:
/* * Like NewError_ns, but with printf style arguments for the message. * You must be careful that your error message length is limited, * so that it doesn't run over the declared buffer size, which you may * want to make a little bigger or smaller. * For an example of its use, see the code for the "GetNode" function, in NeticaEx.c. */ report_ns* NewError (environ_ns* env, int number, errseverity_ns sev, const char* mesg, ...){ va_list ap; char buf[1000]; va_start (ap, mesg); vsprintf (buf, mesg, ap); va_end (ap); return NewError_ns (env, number, sev, buf); }