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

Allow Error instances to be thrown in remote methods #22

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
10 changes: 8 additions & 2 deletions src/jschannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,15 @@
if (typeof e === 'string') {
message = e;
} else if (typeof e === 'object') {
// either an array or an object
// if it's an Error instance we use the constructor name to set the error property
// and we just copy the error message
if (e instanceof Error) {
error = e.constructor.name;
message = e.message;
}
// Otherwise, it's either an array or an object
// * if it's an array of length two, then array[0] is the code, array[1] is the error message
if (e && s_isArray(e) && e.length == 2) {
else if (e && s_isArray(e) && e.length == 2) {
error = e[0];
message = e[1];
}
Expand Down