Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #7392: Error formatting for Ethereum DApp responses (#7393)
Browse files Browse the repository at this point in the history
Fix error formatting for Ethereum DApp responses
  • Loading branch information
StephenHeaps authored May 5, 2023
1 parent b0e539f commit 318250d
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ if (window.isSecureContext) {
"args": JSON.stringify(payload)
})
.then(resolve, (errorJSON) => {
/* remove `Error: ` prefix. errorJSON=`Error: {code: 1, errorMessage: "Internal error"}` */
const errorJSONString = new String(errorJSON);
const errorJSONStringSliced = errorJSONString.slice(errorJSONString.indexOf('{'));
try {
reject(JSON.parse(errorJSON))
reject(JSON.parse(errorJSONStringSliced))
} catch(e) {
reject(errorJSON)
}
Expand Down

0 comments on commit 318250d

Please sign in to comment.