refactor(core): Migrate all errors in cli package to new hierarchy (#13478)

Co-authored-by: Tomi Turtiainen <10324676+tomi@users.noreply.github.com>
This commit is contained in:
Iván Ovejero
2025-02-27 08:30:55 +01:00
committed by GitHub
parent 719e3c2cf7
commit 3ca99194c6
107 changed files with 340 additions and 354 deletions

View File

@@ -4,7 +4,7 @@ import Csrf from 'csrf';
import type { Response } from 'express';
import { Credentials, Logger } from 'n8n-core';
import type { ICredentialDataDecryptedObject, IWorkflowExecuteAdditionalData } from 'n8n-workflow';
import { jsonParse, ApplicationError } from 'n8n-workflow';
import { jsonParse, UnexpectedError } from 'n8n-workflow';
import { RESPONSE_ERROR_MESSAGES, Time } from '@/constants';
import { CredentialsHelper } from '@/credentials-helper';
@@ -171,7 +171,7 @@ export abstract class AbstractOAuthController {
});
if (typeof decoded.cid !== 'string' || typeof decoded.token !== 'string') {
throw new ApplicationError(errorMessage);
throw new UnexpectedError(errorMessage);
}
if (decoded.userId !== req.user?.id) {
@@ -201,7 +201,7 @@ export abstract class AbstractOAuthController {
const state = this.decodeCsrfState(encodedState, req);
const credential = await this.getCredentialWithoutUser(state.cid);
if (!credential) {
throw new ApplicationError('OAuth callback failed because of insufficient permissions');
throw new UnexpectedError('OAuth callback failed because of insufficient permissions');
}
const additionalData = await this.getAdditionalData();
@@ -216,7 +216,7 @@ export abstract class AbstractOAuthController {
);
if (!this.verifyCsrfState(decryptedDataOriginal, state)) {
throw new ApplicationError('The OAuth callback state is invalid!');
throw new UnexpectedError('The OAuth callback state is invalid!');
}
return [credential, decryptedDataOriginal, oauthCredentials];