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

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,7 +17,10 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -17,7 +17,10 @@ ConnectionManager = function(dialect, sequelize) {
try { try {
this.lib = require(sequelize.config.dialectModulePath || 'tedious'); this.lib = require(sequelize.config.dialectModulePath || 'tedious');
} catch (err) { } catch (err) {
throw new Error('Please install tedious package manually'); if (err.code === 'MODULE_NOT_FOUND') {
throw new Error('Please install tedious package manually');
}
throw err;
} }
}; };
......
...@@ -20,7 +20,10 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -20,7 +20,10 @@ ConnectionManager = function(dialect, sequelize) {
this.lib = require('mysql'); this.lib = require('mysql');
} }
} catch (err) { } catch (err) {
throw new Error('Please install mysql package manually'); if (err.code === 'MODULE_NOT_FOUND') {
throw new Error('Please install mysql package manually');
}
throw err;
} }
this.refreshTypeParser(dataTypes); this.refreshTypeParser(dataTypes);
......
...@@ -23,7 +23,10 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -23,7 +23,10 @@ ConnectionManager = function(dialect, sequelize) {
} }
this.lib = sequelize.config.native ? pgLib.native : pgLib; this.lib = sequelize.config.native ? pgLib.native : pgLib;
} catch (err) { } catch (err) {
throw new Error('Please install \'' + (sequelize.config.dialectModulePath || 'pg') + '\' module manually'); if (err.code === 'MODULE_NOT_FOUND') {
throw new Error('Please install \'' + (sequelize.config.dialectModulePath || 'pg') + '\' module manually');
}
throw err;
} }
this.refreshTypeParser(dataTypes.postgres); this.refreshTypeParser(dataTypes.postgres);
......
...@@ -21,7 +21,10 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -21,7 +21,10 @@ 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) {
throw new Error('Please install sqlite3 package manually'); if (err.code === 'MODULE_NOT_FOUND') {
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!