mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix: Show a more user friendly error message if initial Db connection times out (#10682)
This commit is contained in:
14
packages/workflow/src/errors/db-connection-timeout-error.ts
Normal file
14
packages/workflow/src/errors/db-connection-timeout-error.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ApplicationError } from './application.error';
|
||||
|
||||
export type DbConnectionTimeoutErrorOpts = {
|
||||
configuredTimeoutInMs: number;
|
||||
cause: Error;
|
||||
};
|
||||
|
||||
export class DbConnectionTimeoutError extends ApplicationError {
|
||||
constructor(opts: DbConnectionTimeoutErrorOpts) {
|
||||
const numberFormat = Intl.NumberFormat();
|
||||
const errorMessage = `Could not establish database connection within the configured timeout of ${numberFormat.format(opts.configuredTimeoutInMs)} ms. Please ensure the database is configured correctly and the server is reachable. You can increase the timeout by setting the 'DB_POSTGRESDB_CONNECTION_TIMEOUT' environment variable.`;
|
||||
super(errorMessage, { cause: opts.cause });
|
||||
}
|
||||
}
|
||||
9
packages/workflow/src/errors/ensure-error.ts
Normal file
9
packages/workflow/src/errors/ensure-error.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/** Ensures `error` is an `Error */
|
||||
export function ensureError(error: unknown): Error {
|
||||
return error instanceof Error
|
||||
? error
|
||||
: new Error('Error that was not an instance of Error was thrown', {
|
||||
// We should never throw anything except something that derives from Error
|
||||
cause: error,
|
||||
});
|
||||
}
|
||||
@@ -16,3 +16,5 @@ export { TriggerCloseError } from './trigger-close.error';
|
||||
export { NodeError } from './abstract/node.error';
|
||||
export { ExecutionBaseError } from './abstract/execution-base.error';
|
||||
export { ExpressionExtensionError } from './expression-extension.error';
|
||||
export { DbConnectionTimeoutError } from './db-connection-timeout-error';
|
||||
export { ensureError } from './ensure-error';
|
||||
|
||||
Reference in New Issue
Block a user