Creates an instance of the CKEditorError class.
The error id in an error-name format. A link to this error documentation page will be added
to the thrown error's message.
Optionalcontext: objectA context of the error by which the module:watchdog/watchdog~Watchdog watchdog
is able to determine which editor crashed. It should be an editor instance or a property connected to it. It can be also
a null value if the editor should not be restarted in case of the error (e.g. during the editor initialization).
The error context should be checked using the areConnectedThroughProperties( editor, context ) utility
to check if the object works as the context.
Optionaldata: objectAdditional data describing the error. A stringified version of this object will be appended to the error message, so the data are quickly visible in the console. The original data object will also be later available under the #data property.
OptionaloriginalError: ErrorAn optional original error that is being wrapped in the CKEditorError instance.
OptionalcauseReadonlycontextA context of the error by which the Watchdog is able to determine which editor crashed.
Optional ReadonlydataThe additional error data passed to the constructor. Undefined if none was passed.
OptionalstackStaticstackThe Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Checks if the error is of the CKEditorError type.
StaticcaptureCreates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`
The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();
OptionalconstructorOpt: FunctionStaticprepareStaticrethrowA utility that ensures that the thrown error is a module:utils/ckeditorerror~CKEditorError one. It is useful when combined with the module:watchdog/watchdog~Watchdog feature, which can restart the editor in case of a module:utils/ckeditorerror~CKEditorError error.
The error to rethrow.
An object connected through properties with the editor instance. This context will be used by the watchdog to verify which editor should be restarted.
The CKEditor error class.
You should throw
CKEditorErrorwhen:logWarning()and module:utils/ckeditorerror~logErrorlogError()to improve developers experience and let them see the a working editor as soon as possible.