mirror of
https://github.com/n8n-io/n8n.git
synced 2026-08-01 13:35:28 +02:00
40 lines
994 B
TypeScript
40 lines
994 B
TypeScript
import type { Event } from '@sentry/node';
|
|
import callsites from 'callsites';
|
|
|
|
import type { ErrorLevel, ReportingOptions } from './types';
|
|
|
|
/**
|
|
* Deprecated error class kept only for backwards compatibility
|
|
* for community nodes.
|
|
*
|
|
* @deprecated Use `UserError`, `OperationalError` or `UnexpectedError` instead
|
|
*/
|
|
export class ApplicationError extends Error {
|
|
level: ErrorLevel;
|
|
|
|
readonly tags: NonNullable<Event['tags']>;
|
|
|
|
readonly extra?: Event['extra'];
|
|
|
|
readonly packageName?: string;
|
|
|
|
constructor(
|
|
message: string,
|
|
{ level, tags = {}, extra, ...rest }: ErrorOptions & ReportingOptions = {},
|
|
) {
|
|
super(message, rest);
|
|
this.level = level ?? 'error';
|
|
this.tags = tags;
|
|
this.extra = extra;
|
|
|
|
try {
|
|
const filePath = callsites()[2].getFileName() ?? '';
|
|
// eslint-disable-next-line no-useless-escape
|
|
const match = /packages\/([^\/]+)\//.exec(filePath)?.[1];
|
|
|
|
if (match) this.tags.packageName = match;
|
|
// eslint-disable-next-line no-empty
|
|
} catch {}
|
|
}
|
|
}
|