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 79a9c326
authored
Nov 09, 2014
by
Roman Shtylman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keep original error message when wrapping in DatabaseError
fixes #2521
1 parent
c6982f2c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletions
lib/errors.js
test/error.test.js
lib/errors.js
View file @
79a9c32
...
@@ -72,7 +72,7 @@ error.ValidationError.prototype.errors;
...
@@ -72,7 +72,7 @@ error.ValidationError.prototype.errors;
* @constructor
* @constructor
*/
*/
error
.
DatabaseError
=
function
(
parent
)
{
error
.
DatabaseError
=
function
(
parent
)
{
error
.
BaseError
.
apply
(
this
,
arguments
);
error
.
BaseError
.
apply
(
this
,
[
parent
.
message
]
);
this
.
name
=
'SequelizeDatabaseError'
;
this
.
name
=
'SequelizeDatabaseError'
;
this
.
parent
=
parent
;
this
.
parent
=
parent
;
...
...
test/error.test.js
View file @
79a9c32
...
@@ -55,6 +55,14 @@ describe(Support.getTestDialectTeaser("Sequelize Errors"), function () {
...
@@ -55,6 +55,14 @@ describe(Support.getTestDialectTeaser("Sequelize Errors"), function () {
expect
(
matches
).
to
.
have
.
lengthOf
(
1
);
expect
(
matches
).
to
.
have
.
lengthOf
(
1
);
expect
(
matches
[
0
]).
to
.
have
.
property
(
'message'
,
'invalid'
);
expect
(
matches
[
0
]).
to
.
have
.
property
(
'message'
,
'invalid'
);
});
});
it
(
'SequelizeDatabaseError should keep original message'
,
function
()
{
var
orig
=
new
Error
(
'original database error message'
);
var
databaseError
=
new
Sequelize
.
DatabaseError
(
orig
);
expect
(
databaseError
).
to
.
have
.
property
(
'parent'
);
expect
(
databaseError
.
name
).
to
.
equal
(
'SequelizeDatabaseError'
);
expect
(
databaseError
.
message
).
to
.
equal
(
'original database error message'
);
});
});
});
describe
(
'Constraint error'
,
function
()
{
describe
(
'Constraint error'
,
function
()
{
...
...
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