From 34a900820bb7ff4e07b4fa60e191542750ebcdc6 Mon Sep 17 00:00:00 2001 From: chenos Date: Fri, 2 Dec 2022 22:22:11 +0800 Subject: [PATCH] feat(database): provide friendly error message #1185 --- packages/core/database/src/database.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/core/database/src/database.ts b/packages/core/database/src/database.ts index 58450837a..28a668d1e 100644 --- a/packages/core/database/src/database.ts +++ b/packages/core/database/src/database.ts @@ -15,13 +15,17 @@ import { Sequelize, SyncOptions, Transactionable, - Utils, + Utils } from 'sequelize'; import { SequelizeStorage, Umzug } from 'umzug'; import { Collection, CollectionOptions, RepositoryType } from './collection'; import { ImporterReader, ImportFileExtension } from './collection-importer'; +import ReferencesMap from './features/ReferencesMap'; +import { referentialIntegrityCheck } from './features/referential-integrity-check'; import * as FieldTypes from './fields'; import { Field, FieldContext, RelationField } from './fields'; +import { InheritedCollection } from './inherited-collection'; +import InheritanceMap from './inherited-map'; import { MigrationItem, Migrations } from './migration'; import { Model } from './model'; import { ModelHook } from './model-hook'; @@ -53,12 +57,8 @@ import { SyncListener, UpdateListener, UpdateWithAssociationsListener, - ValidateListener, + ValidateListener } from './types'; -import { referentialIntegrityCheck } from './features/referential-integrity-check'; -import ReferencesMap from './features/ReferencesMap'; -import { InheritedCollection } from './inherited-collection'; -import InheritanceMap from './inherited-map'; export interface MergeOptions extends merge.Options {} @@ -498,7 +498,7 @@ export class Database extends EventEmitter implements AsyncEmitter { return true; } catch (error) { if (count >= retry) { - throw error; + throw new Error('Connection failed, please check your database connection credentials and try again.'); } console.log('reconnecting...', count); ++count;