refactor(core): Switch plain errors in cli to ApplicationError (#7857)
Ensure all errors in `cli` are `ApplicationError` or children of it and contain no variables in the message, to continue normalizing all the errors we report to Sentry Follow-up to: https://github.com/n8n-io/n8n/pull/7839
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type express from 'express';
|
||||
import Container, { Service } from 'typedi';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { jsonParse } from 'n8n-workflow';
|
||||
import { ApplicationError, jsonParse } from 'n8n-workflow';
|
||||
import { getServiceProviderInstance } from './serviceProvider.ee';
|
||||
import type { SamlUserAttributes } from './types/samlUserAttributes';
|
||||
import { isSsoJustInTimeProvisioningEnabled } from '../ssoHelpers';
|
||||
@@ -93,7 +93,7 @@ export class SamlService {
|
||||
validate: async (response: string) => {
|
||||
const valid = await validateResponse(response);
|
||||
if (!valid) {
|
||||
throw new Error('Invalid SAML response');
|
||||
throw new ApplicationError('Invalid SAML response');
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -101,7 +101,7 @@ export class SamlService {
|
||||
|
||||
getIdentityProviderInstance(forceRecreate = false): IdentityProviderInstance {
|
||||
if (this.samlify === undefined) {
|
||||
throw new Error('Samlify is not initialized');
|
||||
throw new ApplicationError('Samlify is not initialized');
|
||||
}
|
||||
if (this.identityProviderInstance === undefined || forceRecreate) {
|
||||
this.identityProviderInstance = this.samlify.IdentityProvider({
|
||||
@@ -114,7 +114,7 @@ export class SamlService {
|
||||
|
||||
getServiceProviderInstance(): ServiceProviderInstance {
|
||||
if (this.samlify === undefined) {
|
||||
throw new Error('Samlify is not initialized');
|
||||
throw new ApplicationError('Samlify is not initialized');
|
||||
}
|
||||
return getServiceProviderInstance(this._samlPreferences, this.samlify);
|
||||
}
|
||||
@@ -225,7 +225,7 @@ export class SamlService {
|
||||
} else if (prefs.metadata) {
|
||||
const validationResult = await validateMetadata(prefs.metadata);
|
||||
if (!validationResult) {
|
||||
throw new Error('Invalid SAML metadata');
|
||||
throw new ApplicationError('Invalid SAML metadata');
|
||||
}
|
||||
}
|
||||
this.getIdentityProviderInstance(true);
|
||||
|
||||
Reference in New Issue
Block a user