Skip to content

Commit

Permalink
chore: application start error message (#4477)
Browse files Browse the repository at this point in the history
  • Loading branch information
chareice committed May 24, 2024
1 parent cece85b commit bbbb409
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/core/database/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ export class Database extends EventEmitter implements AsyncEmitter {

/* istanbul ignore next -- @preserve */
async auth(options: Omit<QueryOptions, 'retry'> & { retry?: number | Pick<QueryOptions, 'retry'> } = {}) {
const { retry = 10, ...others } = options;
const { retry = 5, ...others } = options;
const startingDelay = 50;
const timeMultiple = 2;

Expand Down Expand Up @@ -831,7 +831,7 @@ export class Database extends EventEmitter implements AsyncEmitter {
timeMultiple: timeMultiple,
});
} catch (error) {
throw new Error('Connection failed, please check your database connection credentials and try again.');
throw new Error(`Unable to connect to the database`, { cause: error });
}
}

Expand Down
14 changes: 13 additions & 1 deletion packages/core/server/src/gateway/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,20 @@ export const errors: AppErrors = {
APP_ERROR: {
status: 503,
message: ({ app }) => {
return AppSupervisor.getInstance().appErrors[app.name]?.message;
const error = AppSupervisor.getInstance().appErrors[app.name];
if (!error) {
return '';
}

let message = error.message;

if ((error as any).cause) {
message = `${message}: ${(error as any).cause.message}`;
}

return message;
},

code: ({ app }): string => {
const error = AppSupervisor.getInstance().appErrors[app.name];
return error['code'] || 'APP_ERROR';
Expand Down

0 comments on commit bbbb409

Please sign in to comment.