Overview
A generic exception from which all exceptions are derived. MUST only be used for testing, otherwise use a different exception or create a new derived Exception
.
Resolution
As this exception in not meant for production and can really be about anything, the only resolution would be a developer review of the actions around and leading up to the exception and resolve any unexpected code. The developer should also review the details of the exception, and utilize an existing core exception, or create a new exception, that provides more specificity of the reason for the exception.
For developers
Implementation
The implementation of this exception is very straight-forward. For example purposes, we will use TypeScript.
The exception must have an exception message, which should provide a description of the reason the exception is being created.
const exc = new Exception('I am simply testing a feature and need to throw something for now.');
throw exc;
The exception also accepts an optional exception data parameter, which accepts any key/value pair.
A special key is the cause
key identifying a previous exception. This is useful when you are unable to gracefully (silently) handle errors or exceptions from third-party code, and need to identify the actual cause of the exception, while presenting a more specific cause.
try {
someThirdPartyThrow();
} catch (e) {
const err = e as Error;
// ... Attempt to handle gracefully
if (err instanceof Error) {
const exc = new Exception('Unable to handled internal error.', { cause: err });
throw exc;
}
}
Meta
- Exception code: 0x0 (0)