Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rsvp.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
rsvp.js
Commits
c9233289
Commit
c9233289
authored
Apr 27, 2013
by
Teddy Zeenny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reject promise if resolver function throws an exception
parent
40b8bf24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
lib/rsvp/promise.js
lib/rsvp/promise.js
+5
-1
tests/extension-tests.js
tests/extension-tests.js
+9
-0
No files found.
lib/rsvp/promise.js
View file @
c9233289
...
...
@@ -41,7 +41,11 @@ var Promise = function(resolver) {
this
.
trigger
(
'
error
'
,
{
detail
:
event
.
detail
});
},
this
);
resolver
(
resolvePromise
,
rejectPromise
);
try
{
resolver
(
resolvePromise
,
rejectPromise
);
}
catch
(
e
)
{
rejectPromise
(
e
);
}
};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
...
...
tests/extension-tests.js
View file @
c9233289
...
...
@@ -81,6 +81,15 @@ describe("RSVP extensions", function() {
},
TypeError
);
});
it
(
'
should reject on resolver exception
'
,
function
(
done
)
{
var
promise
=
RSVP
.
Promise
(
function
()
{
throw
'
error
'
;
}).
then
(
null
,
function
(
e
)
{
assert
.
equal
(
e
,
'
error
'
);
done
();
});
});
describe
(
'
assimilation
'
,
function
()
{
it
(
'
should assimilate if `resolve` is called with a fulfilled promise
'
,
function
(
done
)
{
var
originalPromise
=
new
RSVP
.
Promise
(
function
(
resolve
)
{
resolve
(
'
original value
'
);
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment