mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Move ApplicationError to @n8n/errors (#17667)
This commit is contained in:
@@ -38,8 +38,8 @@
|
||||
"devDependencies": {
|
||||
"@langchain/core": "catalog:",
|
||||
"@n8n/config": "workspace:*",
|
||||
"@n8n/vitest-config": "workspace:*",
|
||||
"@n8n/typescript-config": "workspace:*",
|
||||
"@n8n/vitest-config": "workspace:*",
|
||||
"@types/express": "catalog:",
|
||||
"@types/jmespath": "^0.15.0",
|
||||
"@types/lodash": "catalog:",
|
||||
@@ -50,6 +50,7 @@
|
||||
"vitest-mock-extended": "catalog:"
|
||||
},
|
||||
"dependencies": {
|
||||
"@n8n/errors": "workspace:^",
|
||||
"@n8n/tournament": "1.0.6",
|
||||
"ast-types": "0.15.2",
|
||||
"callsites": "catalog:",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ApplicationError, type ReportingOptions } from '@n8n/errors';
|
||||
|
||||
import type { Functionality, IDataObject, JsonObject } from '../../interfaces';
|
||||
import { ApplicationError } from '../application.error';
|
||||
import type { ReportingOptions } from '../error.types';
|
||||
|
||||
interface ExecutionBaseErrorOptions extends ReportingOptions {
|
||||
cause?: Error;
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import type { Event } from '@sentry/node';
|
||||
import callsites from 'callsites';
|
||||
|
||||
import type { ErrorLevel, ReportingOptions } from './error.types';
|
||||
|
||||
/**
|
||||
* @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() ?? '';
|
||||
const match = /packages\/([^\/]+)\//.exec(filePath)?.[1];
|
||||
|
||||
if (match) this.tags.packageName = match;
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Event } from '@sentry/node';
|
||||
import callsites from 'callsites';
|
||||
|
||||
import type { ErrorTags, ErrorLevel, ReportingOptions } from '../error.types';
|
||||
import type { ErrorTags, ErrorLevel, ReportingOptions } from '@n8n/errors';
|
||||
|
||||
export type BaseErrorOptions = { description?: string | undefined | null } & ErrorOptions &
|
||||
ReportingOptions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApplicationError } from './application.error';
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
|
||||
export type DbConnectionTimeoutErrorOpts = {
|
||||
configuredTimeoutInMs: number;
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import type { Event } from '@sentry/node';
|
||||
|
||||
export type ErrorLevel = 'fatal' | 'error' | 'warning' | 'info';
|
||||
|
||||
export type ErrorTags = NonNullable<Event['tags']>;
|
||||
|
||||
export type ReportingOptions = {
|
||||
/** Whether the error should be reported to Sentry */
|
||||
shouldReport?: boolean;
|
||||
/** Whether the error log should be logged (default to true) */
|
||||
shouldBeLogged?: boolean;
|
||||
level?: ErrorLevel;
|
||||
tags?: ErrorTags;
|
||||
extra?: Event['extra'];
|
||||
executionId?: string;
|
||||
};
|
||||
@@ -1,9 +1,8 @@
|
||||
export type * from './error.types';
|
||||
export { BaseError, type BaseErrorOptions } from './base/base.error';
|
||||
export { OperationalError, type OperationalErrorOptions } from './base/operational.error';
|
||||
export { UnexpectedError, type UnexpectedErrorOptions } from './base/unexpected.error';
|
||||
export { UserError, type UserErrorOptions } from './base/user.error';
|
||||
export { ApplicationError } from './application.error';
|
||||
export { ApplicationError } from '@n8n/errors';
|
||||
export { ExpressionError } from './expression.error';
|
||||
export { ExecutionCancelledError } from './execution-cancelled.error';
|
||||
export { NodeApiError } from './node-api.error';
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { AxiosError } from 'axios';
|
||||
import { parseString } from 'xml2js';
|
||||
|
||||
import { NodeError } from './abstract/node.error';
|
||||
import type { ErrorLevel } from './error.types';
|
||||
import type { ErrorLevel } from '@n8n/errors';
|
||||
import {
|
||||
NO_OP_NODE_TYPE,
|
||||
UNKNOWN_ERROR_DESCRIPTION,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NodeError } from './abstract/node.error';
|
||||
import { ApplicationError } from './application.error';
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
import type { NodeOperationErrorOptions } from './node-api.error';
|
||||
import type { INode, JsonObject } from '../interfaces';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { ApplicationError } from './application.error';
|
||||
import type { ErrorLevel } from './error.types';
|
||||
import { ApplicationError, type ErrorLevel } from '@n8n/errors';
|
||||
import type { INode } from '../interfaces';
|
||||
|
||||
interface TriggerCloseErrorOptions extends ErrorOptions {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ExecutionBaseError } from './abstract/execution-base.error';
|
||||
import type { ApplicationError } from './application.error';
|
||||
import type { ApplicationError } from '@n8n/errors';
|
||||
import type { INode } from '../interfaces';
|
||||
|
||||
interface WorkflowActivationErrorOptions {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DateTime, Duration, Interval } from 'luxon';
|
||||
|
||||
import { ApplicationError } from './errors/application.error';
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
import { ExpressionExtensionError } from './errors/expression-extension.error';
|
||||
import { ExpressionError } from './errors/expression.error';
|
||||
import { evaluateExpression, setErrorHandler } from './expression-evaluator-proxy';
|
||||
|
||||
@@ -7,7 +7,7 @@ import get from 'lodash/get';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
|
||||
import { EXECUTE_WORKFLOW_NODE_TYPE, WORKFLOW_TOOL_LANGCHAIN_NODE_TYPE } from './constants';
|
||||
import { ApplicationError } from './errors/application.error';
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
import { NodeConnectionTypes } from './interfaces';
|
||||
import type {
|
||||
FieldType,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { DateTime } from 'luxon';
|
||||
|
||||
import { ApplicationError } from '../errors/application.error';
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
import type {
|
||||
FilterConditionValue,
|
||||
FilterOperatorType,
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
WEBHOOK_NODE_TYPE,
|
||||
WORKFLOW_TOOL_LANGCHAIN_NODE_TYPE,
|
||||
} from './constants';
|
||||
import { ApplicationError } from './errors/application.error';
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
import type { NodeApiError } from './errors/node-api.error';
|
||||
import type {
|
||||
IConnection,
|
||||
|
||||
@@ -4,7 +4,7 @@ import FormData from 'form-data';
|
||||
import merge from 'lodash/merge';
|
||||
|
||||
import { ALPHABET } from './constants';
|
||||
import { ApplicationError } from './errors/application.error';
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
import { ExecutionCancelledError } from './errors/execution-cancelled.error';
|
||||
import type { BinaryFileType, IDisplayOptions, INodeProperties, JsonObject } from './interfaces';
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { DateTime, Duration, Interval, Settings } from 'luxon';
|
||||
|
||||
import { augmentArray, augmentObject } from './augment-object';
|
||||
import { AGENT_LANGCHAIN_NODE_TYPE, SCRIPTING_NODE_TYPES } from './constants';
|
||||
import { ApplicationError } from './errors/application.error';
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
import {
|
||||
ExpressionError,
|
||||
type ExpressionErrorOptions,
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
STARTING_NODE_TYPES,
|
||||
} from './constants';
|
||||
import { UserError } from './errors';
|
||||
import { ApplicationError } from './errors/application.error';
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
import { Expression } from './expression';
|
||||
import { getGlobalState } from './global-state';
|
||||
import type {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ALPHABET } from '../src/constants';
|
||||
import { ApplicationError } from '../src/errors/application.error';
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
import { ExecutionCancelledError } from '../src/errors/execution-cancelled.error';
|
||||
import {
|
||||
jsonParse,
|
||||
|
||||
Reference in New Issue
Block a user