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

Caller now can now pass error as string (old behavior) or dictionary #39

Merged
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
2 changes: 1 addition & 1 deletion dist/AlphaWallet-min.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion dist/AlphaWallet.js
Original file line number Diff line number Diff line change
@@ -39974,7 +39974,12 @@ var AlphaWallet = {
var callback = callbacks[id];

if (callback.isRPC) {
var response = { 'id': id, jsonrpc: '2.0', result: value, error: { message: error } };
var response;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oa-s is it better to check error if it's just a string and keep the old behavior?

if error is string //I forgot my JavaScript
    error: { message: error }
else
    error: error
end

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, looks good

if (obj instanceof Object && !(obj instanceof Array)) {
response = { 'id': id, jsonrpc: '2.0', result: value, error: error };
} else {
response = { 'id': id, jsonrpc: '2.0', result: value, error: { message: error } };
}

if (error) {
callback(response, null);
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -63,7 +63,12 @@ const AlphaWallet = {
let callback = callbacks[id]

if (callback.isRPC) {
const response = {'id': id, jsonrpc: '2.0', result: value, error: {message: error} }
var response
if (obj instanceof Object && !(obj instanceof Array)) {
response = {'id': id, jsonrpc: '2.0', result: value, error: error }
} else {
response = {'id': id, jsonrpc: '2.0', result: value, error: {message: error} }
}

if (error) {
callback(response, null)