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:
Iván Ovejero
2023-11-28 10:19:27 +01:00
committed by GitHub
parent 38f24a6184
commit 1c6178759c
81 changed files with 346 additions and 297 deletions

View File

@@ -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',
);
}