@w5s/errorFunctionsRuntimeErrorSur cette pageRuntimeError CallableRuntimeError(...properties: [properties?: ParametersProperties<RuntimeError>]): RuntimeErrorIndex ConstructorcreateOthererrorNamehasInstanceConstructor readonlycreatecreate: (...properties: [properties?: ParametersProperties<RuntimeError>]) => RuntimeErrorReturn a new CustomError@exampleconst MyError = CustomError.define('MyError1');const error = MyError.create({ message: 'my custom message', // customize message (optional) cause: parentError, // Error that caused this error (optional)})Other readonlyerrorNameerrorName: RuntimeErrorThe model name constant. Can be useful for switch / case statements.@exampleconst error: SomeError;switch (error.name) { case SomeError.errorName: //...}readonlyhasInstancehasInstance: (anyValue: unknown) => anyValue is RuntimeErrorPredicate that returns true when anyValue is a Model The implementation compares anyValue.name === Module.errorName@exampleconst MyError = CustomError.define('MyError1');const unknownError: unknown;if (MyError.hasInstance(unknownError)) { // unknownError.name === 'MyError1'}
Return a new
CustomError