不要怂,就是干,撸起袖子干!

Commit 887a0331 by Yoyo Zhou Committed by Mick Hansen

ConnectionManager: Re-throw initialization errors unless they are MODULE_NOT_FOUND (#5784)

As described in https://github.com/sequelize/sequelize/issues/3302#issuecomment-199238449
1 parent cf4fb27e
...@@ -17,8 +17,11 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -17,8 +17,11 @@ ConnectionManager = function(dialect, sequelize) {
try { try {
this.lib = require(sequelize.config.dialectModulePath || 'tedious'); this.lib = require(sequelize.config.dialectModulePath || 'tedious');
} catch (err) { } catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
throw new Error('Please install tedious package manually'); throw new Error('Please install tedious package manually');
} }
throw err;
}
}; };
Utils._.extend(ConnectionManager.prototype, AbstractConnectionManager.prototype); Utils._.extend(ConnectionManager.prototype, AbstractConnectionManager.prototype);
......
...@@ -20,8 +20,11 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -20,8 +20,11 @@ ConnectionManager = function(dialect, sequelize) {
this.lib = require('mysql'); this.lib = require('mysql');
} }
} catch (err) { } catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
throw new Error('Please install mysql package manually'); throw new Error('Please install mysql package manually');
} }
throw err;
}
this.refreshTypeParser(dataTypes); this.refreshTypeParser(dataTypes);
}; };
......
...@@ -23,8 +23,11 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -23,8 +23,11 @@ ConnectionManager = function(dialect, sequelize) {
} }
this.lib = sequelize.config.native ? pgLib.native : pgLib; this.lib = sequelize.config.native ? pgLib.native : pgLib;
} catch (err) { } catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
throw new Error('Please install \'' + (sequelize.config.dialectModulePath || 'pg') + '\' module manually'); throw new Error('Please install \'' + (sequelize.config.dialectModulePath || 'pg') + '\' module manually');
} }
throw err;
}
this.refreshTypeParser(dataTypes.postgres); this.refreshTypeParser(dataTypes.postgres);
}; };
......
...@@ -21,8 +21,11 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -21,8 +21,11 @@ ConnectionManager = function(dialect, sequelize) {
try { try {
this.lib = require(sequelize.config.dialectModulePath || 'sqlite3').verbose(); this.lib = require(sequelize.config.dialectModulePath || 'sqlite3').verbose();
} catch (err) { } catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
throw new Error('Please install sqlite3 package manually'); throw new Error('Please install sqlite3 package manually');
} }
throw err;
}
this.refreshTypeParser(dataTypes); this.refreshTypeParser(dataTypes);
}; };
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!