Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch error when set error@context prop #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions context.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ Namespace.prototype.run = function (fn) {
return context;
}
catch (exception) {
if (exception) {
try {
exception[ERROR_SYMBOL] = context;
}
catch (e) {}
throw exception;
}
finally {
Expand Down Expand Up @@ -84,9 +85,10 @@ Namespace.prototype.bind = function (fn, context) {
return fn.apply(this, arguments);
}
catch (exception) {
if (exception) {
try {
exception[ERROR_SYMBOL] = context;
}
catch (e) {}
throw exception;
}
finally {
Expand Down Expand Up @@ -161,7 +163,7 @@ Namespace.prototype.bindEmitter = function (emitter) {
* @param {Error} exception Possibly annotated error.
*/
Namespace.prototype.fromException = function (exception) {
return exception[ERROR_SYMBOL];
return exception && exception[ERROR_SYMBOL];
};

function get(name) {
Expand Down