ReportErrors {RNetica} | R Documentation |
This function is normally called at the end of other Netica calls to report out on any Netica errors. These functions are not normally needed at the user level.
ReportErrors(maxreport = 9, clear = TRUE, session=getDefaultSession()) ClearAllErrors(severity="XXX_ERR",session=getDefaultSession()) logErrors(allErrs) flogErrors(allErrs) printErrors(allErrs)
maxreport |
An integer giving the maximum number errors to report. |
clear |
A logical flag indicating if errors should be cleared as they are reported (default is to clear errors). |
severity |
A string giving one of the Netica error levels (in
order of severity): |
session |
An object of class |
allErrs |
This is a list of length 5, with each element a
character vector containing the error messages for |
More information about the severity levels of Netica errors can be
found in the documentation for the Netica function
GetError_ns
. The ClearAllErrors()
function clears all
errors of the indicated severity and below.
Note that these functions are really just wrappers for
session$reportErrors
and session$clearErrors
(see
NeticaSession
).
The latest version now uses flog.logger
to log the errors. This allows the level of logging to be controlled
as well as allow for easy redirection of the Netica errors into a log
file.
ReportErrors()
returns a count of the number of errors of
severity "ERROR_ERR"
or higher.
The function ReportErrors
is implemented as follows. First, it
calls the reportErrors
method of the
NeticaSession
object. This generates a list of
vectors of error messages (allErrs
). This is passed to the
logErrors
function which reports the errors and returns the
vector of counts.
The flogErrors
function logs the errors using
flog.logger
. The function
printErrors
simply prints them to the console. To remove the
use of futile.logger
redefine logErrors
to use
printErrors
instead of logErrors
.
At this point, the protocol is that the higher level RNetica functions
all call ReportErrors()
to report error messages and warnings
and then throw an error (call stop()
) whenever the
error count is greater than one. These functions are probably not
necessary in user level code.
As of version 0.5, this is modified so that functions follow the
NeticaNode
to the NeticaBN
to the NeticaSession
and then call the report
error mechanism on that.
Future versions may use a more sophisticated error checking mechanism that allows for more user control.
There was a known bug where ReportErrors
keeps
finding an error that indicates that there is an invalid error pointer
(which keeps retriggering the error). This should now be fixed.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: GetError_ns(), ClearError_ns()
StopNetica()
– should be called after
"XXX_ERROR"
is signaled by Netica.
flog.logger
– describes the logging
mechanism.
myCreateNetwork <- function (names,session) { handles <- .Call("RN_New_Net",as.character(names),session,PACKAGE="RNetica") ## Check for errors ecount <- ReportErrors() if (ecount[1]>0) { ## Stop if errors are encountered stop("CreateNetwork: Netica Errors Encountered, see console for details.") } handles } ## Not run: ClearAllErrors(getDefaultSession()) getDefaultSession()$clearErrors() ## End(Not run)