Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 6e0cf9d6
authored
Nov 13, 2014
by
David Pate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an error for connections timing out. Updated Postgres connection manager t…
…o use the new errors.
1 parent
ffc35bb1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
lib/dialects/postgres/connection-manager.js
lib/errors.js
lib/dialects/postgres/connection-manager.js
View file @
6e0cf9d
...
...
@@ -2,7 +2,8 @@
var
AbstractConnectionManager
=
require
(
'../abstract/connection-manager'
)
,
ConnectionManager
,
Utils
=
require
(
'../../utils'
)
,
Promise
=
require
(
'../../promise'
);
,
Promise
=
require
(
'../../promise'
)
,
sequelizeErrors
=
require
(
'../../errors'
);
ConnectionManager
=
function
(
dialect
,
sequelize
)
{
AbstractConnectionManager
.
call
(
this
,
dialect
,
sequelize
);
...
...
@@ -56,19 +57,23 @@ ConnectionManager.prototype.connect = function(config) {
if
(
err
.
code
)
{
switch
(
err
.
code
)
{
case
'ECONNREFUSED'
:
reject
(
new
Error
(
'Failed to authenticate for PostgresSQL. Please double check your settings.'
));
reject
(
new
sequelizeErrors
.
ConnectionRefusedError
(
err
));
break
;
case
'ENOTFOUND'
:
reject
(
new
sequelizeErrors
.
HostNotFoundError
(
err
));
break
;
case
'EHOSTUNREACH'
:
reject
(
new
sequelizeErrors
.
HostNotReachableError
(
err
));
break
;
case
'EINVAL'
:
reject
(
new
Error
(
'Failed to find PostgresSQL server. Please double check your settings.'
));
reject
(
new
sequelizeErrors
.
InvalidConnectionError
(
err
));
break
;
default
:
reject
(
err
);
reject
(
new
sequelizeErrors
.
ConnectionError
(
err
)
);
break
;
}
}
else
{
reject
(
new
Error
(
err
.
message
));
reject
(
new
sequelizeErrors
.
ConnectionError
(
err
));
}
return
;
}
...
...
@@ -79,7 +84,7 @@ ConnectionManager.prototype.connect = function(config) {
// If we didn't ever hear from the client.connect() callback the connection timeout, node-postgres does not treat this as an error since no active query was ever emitted
connection
.
on
(
'end'
,
function
()
{
if
(
!
responded
)
{
reject
(
new
Error
(
'Connection timed out'
));
reject
(
new
sequelizeErrors
.
ConnectionTimedOutError
(
new
Error
(
'Connection timed out'
)
));
}
});
}).
tap
(
function
(
connection
)
{
...
...
lib/errors.js
View file @
6e0cf9d
...
...
@@ -169,6 +169,17 @@ error.InvalidConnectionError = function (parent) {
util
.
inherits
(
error
.
InvalidConnectionError
,
error
.
ConnectionError
);
/**
* Thrown when a connection to a database times out
* @extends ConnectionError
* @constructor
*/
error
.
ConnectionTimedOutError
=
function
(
parent
)
{
error
.
ConnectionTimedOutError
.
call
(
this
,
parent
);
this
.
name
=
'SequelizeConnectionTimedOutError'
;
};
util
.
inherits
(
error
.
ConnectionTimedOutError
,
error
.
ConnectionError
);
/**
* Thrown when a database query times out because of a deadlock
* @extends DatabaseError
* @constructor
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment