mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
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:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user