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
84469f63
Commit
84469f63
authored
Apr 27, 2013
by
Stefan Penner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #75 from teddyzeenny/constructor-reject
Reject promise if resolver function throws an exception
parents
40b8bf24
c9233289
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 @
84469f63
...
@@ -41,7 +41,11 @@ var Promise = function(resolver) {
...
@@ -41,7 +41,11 @@ var Promise = function(resolver) {
this
.
trigger
(
'
error
'
,
{
detail
:
event
.
detail
});
this
.
trigger
(
'
error
'
,
{
detail
:
event
.
detail
});
},
this
);
},
this
);
resolver
(
resolvePromise
,
rejectPromise
);
try
{
resolver
(
resolvePromise
,
rejectPromise
);
}
catch
(
e
)
{
rejectPromise
(
e
);
}
};
};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
...
...
tests/extension-tests.js
View file @
84469f63
...
@@ -81,6 +81,15 @@ describe("RSVP extensions", function() {
...
@@ -81,6 +81,15 @@ describe("RSVP extensions", function() {
},
TypeError
);
},
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
()
{
describe
(
'
assimilation
'
,
function
()
{
it
(
'
should assimilate if `resolve` is called with a fulfilled promise
'
,
function
(
done
)
{
it
(
'
should assimilate if `resolve` is called with a fulfilled promise
'
,
function
(
done
)
{
var
originalPromise
=
new
RSVP
.
Promise
(
function
(
resolve
)
{
resolve
(
'
original value
'
);
});
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