WFJSL Error Handling
| WFJSL Documentation Home | WFJSL TypeDoc Reference | Whiteflag Specification |
Overview
In addition to the standard JavaScript Error class, WFJSL provides an
additional error class for Whiteflag protocol errors: the WfProtocolError
class for the handling of Whiteflag message format and protocol errors.
Usage of error classes
To use the WfProtocolError class, import it with an object destructor:
const { WfProtocolError } = require('whiteflag-js');
and define a new error as needed:
err = new WfProtocolError(message, causes, code);
with the following arguments:
messageis similar to the property of the generic Error class, i.e. a string with a human-readable description of the errorcausesis an additional property in the form of an array that may contain a human-readable stack of underlying causescodeis a property of type string, identifying the type of error as described below for both classes
ProtocolError class error codes
WF_PROTOCOL_ERROR: generic Whiteflag protocol error (default)WF_METAHEADER_ERROR: incorrect Whiteflag message metadataWF_FORMAT_ERROR: Whiteflag message format errorWF_REFERENCE_ERROR: Whiteflag message reference errorWF_AUTH_ERROR: Whiteflag message authentication errorWF_SIGN_ERROR: Whiteflag signature errorWF_ENCRYPTION_ERROR: Whiteflag encryption error