mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-04 05:08:42 +08:00
chore: application start error message (#4477)
This commit is contained in:
parent
cece85b335
commit
bbbb409565
@ -801,7 +801,7 @@ export class Database extends EventEmitter implements AsyncEmitter {
|
|||||||
|
|
||||||
/* istanbul ignore next -- @preserve */
|
/* istanbul ignore next -- @preserve */
|
||||||
async auth(options: Omit<QueryOptions, 'retry'> & { retry?: number | Pick<QueryOptions, 'retry'> } = {}) {
|
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 startingDelay = 50;
|
||||||
const timeMultiple = 2;
|
const timeMultiple = 2;
|
||||||
|
|
||||||
@ -831,7 +831,7 @@ export class Database extends EventEmitter implements AsyncEmitter {
|
|||||||
timeMultiple: timeMultiple,
|
timeMultiple: timeMultiple,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} 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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +34,20 @@ export const errors: AppErrors = {
|
|||||||
APP_ERROR: {
|
APP_ERROR: {
|
||||||
status: 503,
|
status: 503,
|
||||||
message: ({ app }) => {
|
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 => {
|
code: ({ app }): string => {
|
||||||
const error = AppSupervisor.getInstance().appErrors[app.name];
|
const error = AppSupervisor.getInstance().appErrors[app.name];
|
||||||
return error['code'] || 'APP_ERROR';
|
return error['code'] || 'APP_ERROR';
|
||||||
|
Loading…
Reference in New Issue
Block a user