mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor(core): Reorganize error hierarchy in cli package (no-changelog) (#7839)
Ensure all errors in `cli` inherit from `ApplicationError` to continue normalizing all the errors we report to Sentry Follow-up to: https://github.com/n8n-io/n8n/pull/7820
This commit is contained in:
@@ -14,6 +14,7 @@ import { Container } from 'typedi';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import { listQueryMiddleware } from '@/middlewares';
|
||||
import { Logger } from '@/Logger';
|
||||
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||
|
||||
export const credentialsController = express.Router();
|
||||
credentialsController.use('/', EECredentialsController);
|
||||
@@ -60,9 +61,7 @@ credentialsController.get(
|
||||
const sharing = await CredentialsService.getSharing(req.user, credentialId, ['credentials']);
|
||||
|
||||
if (!sharing) {
|
||||
throw new ResponseHelper.NotFoundError(
|
||||
`Credential with ID "${credentialId}" could not be found.`,
|
||||
);
|
||||
throw new NotFoundError(`Credential with ID "${credentialId}" could not be found.`);
|
||||
}
|
||||
|
||||
const { credentials: credential } = sharing;
|
||||
@@ -145,7 +144,7 @@ credentialsController.patch(
|
||||
userId: req.user.id,
|
||||
},
|
||||
);
|
||||
throw new ResponseHelper.NotFoundError(
|
||||
throw new NotFoundError(
|
||||
'Credential to be updated not found. You can only update credentials owned by you',
|
||||
);
|
||||
}
|
||||
@@ -165,9 +164,7 @@ credentialsController.patch(
|
||||
const responseData = await CredentialsService.update(credentialId, newCredentialData);
|
||||
|
||||
if (responseData === null) {
|
||||
throw new ResponseHelper.NotFoundError(
|
||||
`Credential ID "${credentialId}" could not be found to be updated.`,
|
||||
);
|
||||
throw new NotFoundError(`Credential ID "${credentialId}" could not be found to be updated.`);
|
||||
}
|
||||
|
||||
// Remove the encrypted data as it is not needed in the frontend
|
||||
@@ -197,7 +194,7 @@ credentialsController.delete(
|
||||
userId: req.user.id,
|
||||
},
|
||||
);
|
||||
throw new ResponseHelper.NotFoundError(
|
||||
throw new NotFoundError(
|
||||
'Credential to be deleted not found. You can only removed credentials owned by you',
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user