mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 08:34:07 -08:00
45 lines
1 KiB
TypeScript
45 lines
1 KiB
TypeScript
import { ApplicationError } from 'n8n-workflow';
|
|
|
|
export class ValidationError extends ApplicationError {
|
|
description = '';
|
|
|
|
itemIndex: number | undefined = undefined;
|
|
|
|
context: { itemIndex: number } | undefined = undefined;
|
|
|
|
lineNumber: number | undefined = undefined;
|
|
|
|
constructor({
|
|
message,
|
|
description,
|
|
itemIndex,
|
|
lineNumber,
|
|
}: {
|
|
message: string;
|
|
description: string;
|
|
itemIndex?: number;
|
|
lineNumber?: number;
|
|
}) {
|
|
super(message);
|
|
|
|
this.lineNumber = lineNumber;
|
|
this.itemIndex = itemIndex;
|
|
|
|
if (this.lineNumber !== undefined && this.itemIndex !== undefined) {
|
|
this.message = `${message} [line ${lineNumber}, for item ${itemIndex}]`;
|
|
} else if (this.lineNumber !== undefined) {
|
|
this.message = `${message} [line ${lineNumber}]`;
|
|
} else if (this.itemIndex !== undefined) {
|
|
this.message = `${message} [item ${itemIndex}]`;
|
|
} else {
|
|
this.message = message;
|
|
}
|
|
|
|
this.description = description;
|
|
|
|
if (this.itemIndex !== undefined) {
|
|
this.context = { itemIndex: this.itemIndex };
|
|
}
|
|
}
|
|
}
|