@tmlmt/cooklang-parser / DuplicateCategoryError
Class: DuplicateCategoryError
Thrown when a category name is declared more than once in a CategoryConfig.
Extends
Constructors
Constructor
new DuplicateCategoryError(
categoryName):DuplicateCategoryError
Parameters
categoryName
string
Returns
DuplicateCategoryError
Overrides
SingleDiagnosticError.constructor
Properties
categoryName
readonlycategoryName:string
cause?
optionalcause?:unknown
Inherited from
code
readonlycode:"COOKLANG_E0101"|"COOKLANG_E0102"|"COOKLANG_W0101"|"COOKLANG_E0201"|"COOKLANG_E0202"|"COOKLANG_E0203"|"COOKLANG_E0204"|"COOKLANG_W0201"|"COOKLANG_W0202"|"COOKLANG_E0301"|"COOKLANG_E0302"|"COOKLANG_W0301"|"COOKLANG_I0401"|"COOKLANG_W0401"|"COOKLANG_E9401"|"COOKLANG_E9402"|"COOKLANG_E9501"|"COOKLANG_E9502"|"COOKLANG_E9503"|"COOKLANG_E9504"|"COOKLANG_E9505"|"COOKLANG_E9601"|"COOKLANG_E9602"|"COOKLANG_E9603"|"COOKLANG_E9604"|"COOKLANG_W0601"|"COOKLANG_E9701"|"COOKLANG_W0701"|"COOKLANG_W0702"|"COOKLANG_E0701"|"COOKLANG_E0702"
Shortcut for diagnostic.code.
Inherited from
diagnostic
readonlydiagnostic:Diagnostic
The structured diagnostic describing this error.
Inherited from
SingleDiagnosticError.diagnostic
diagnostics
readonlydiagnostics:Diagnostic[]
All diagnostics carried by this error (always at least one).
Inherited from
SingleDiagnosticError.diagnostics
message
message:
string
Inherited from
name
name:
string
Inherited from
source?
readonlyoptionalsource?:string
The original text used for parsing, when thrown by a parse() method. Pass to formatDiagnostic for code-frame output.
Inherited from
stack?
optionalstack?:string
Inherited from
stackTraceLimit
staticstackTraceLimit:number
The 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.
Inherited from
SingleDiagnosticError.stackTraceLimit
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Creates 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();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
SingleDiagnosticError.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces