@@ -50,11 +50,11 @@ exports.use = function (connection, proto, opts, cb) {
5050
5151exports . connect = function ( opts , cb ) {
5252 if ( arguments . length === 0 || ! opts ) {
53- return ORM_Error ( new Error ( "CONNECTION_URL_EMPTY" ) , cb ) ;
53+ return ORM_Error ( ErrorCodes . generateError ( ErrorCodes . PARAM_MISSMATCH , "CONNECTION_URL_EMPTY" ) , cb ) ;
5454 }
5555 if ( typeof opts == "string" ) {
5656 if ( opts . replace ( / \s + / , "" ) . length === 0 ) {
57- return ORM_Error ( new Error ( "CONNECTION_URL_EMPTY" ) , cb ) ;
57+ return ORM_Error ( ErrorCodes . generateError ( ErrorCodes . PARAM_MISSMATCH , "CONNECTION_URL_EMPTY" ) , cb ) ;
5858 }
5959 opts = url . parse ( opts , true ) ;
6060 }
@@ -65,7 +65,7 @@ exports.connect = function (opts, cb) {
6565 opts . database = ( opts . pathname ? opts . pathname . substr ( 1 ) : "" ) ;
6666 }
6767 if ( ! opts . protocol ) {
68- return ORM_Error ( new Error ( "CONNECTION_URL_NO_PROTOCOL" ) , cb ) ;
68+ return ORM_Error ( ErrorCodes . generateError ( ErrorCodes . PARAM_MISSMATCH , "CONNECTION_URL_NO_PROTOCOL" ) , cb ) ;
6969 }
7070 // if (!opts.host) {
7171 // opts.host = opts.hostname = "localhost";
@@ -111,7 +111,7 @@ exports.connect = function (opts, cb) {
111111 } ) ;
112112 } catch ( ex ) {
113113 if ( ex . code == "MODULE_NOT_FOUND" || ex . message . indexOf ( 'find module' ) ) {
114- return ORM_Error ( new Error ( "CONNECTION_PROTOCOL_NOT_SUPPORTED" ) , cb ) ;
114+ return ORM_Error ( ErrorCodes . generateError ( ErrorCodes . NO_SUPPORT , "CONNECTION_PROTOCOL_NOT_SUPPORTED" ) , cb ) ;
115115 }
116116 return ORM_Error ( ex , cb ) ;
117117 }
@@ -138,7 +138,7 @@ function ORM(driver_name, driver, settings) {
138138 var onError = function ( err ) {
139139 if ( this . settings . get ( "connection.reconnect" ) ) {
140140 if ( typeof this . driver . reconnect == "undefined" ) {
141- return this . emit ( "error" , new Error ( "Connection lost - driver does not support reconnection" ) ) ;
141+ return this . emit ( "error" , ErrorCodes . generateError ( ErrorCodes . CONNECTION_LOST , "Connection lost - driver does not support reconnection" ) ) ;
142142 }
143143 this . driver . reconnect ( function ( ) {
144144 this . driver . on ( "error" , onError ) ;
0 commit comments