Skip to content

Commit

Permalink
feat(support error from app): support throw the error message form th…
Browse files Browse the repository at this point in the history
…e app
  • Loading branch information
Littleor committed May 25, 2022
1 parent 11760fb commit 78be87d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ export class Provider implements IProvider {
this
)
} catch (e) {
console.error('[AnyWeb] Error to sendTransaction', e)
return e
throw new ProviderRpcError(
ProviderErrorCode.SendTransactionError,
'Error to sendTransaction: ' + e
)
}
case 'anyweb_importAccount':
try {
Expand All @@ -293,8 +295,10 @@ export class Provider implements IProvider {
this
)
} catch (e) {
console.error('[AnyWeb] Error to import Address', e)
return e
throw new ProviderRpcError(
ProviderErrorCode.ImportAddressError,
'Error to import Address: ' + e
)
}
case 'anyweb_version':
return config.version
Expand Down
3 changes: 3 additions & 0 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ export enum ProviderErrorCode {
ChainDisconnected = 4901,
SDKNotReady = 5000,
ParamsError = 6000,
RequestError = 7000,
SendTransactionError = 7001,
ImportAddressError = 7002,
}

export class ProviderRpcError extends Error implements IProviderRpcError {
Expand Down

0 comments on commit 78be87d

Please sign in to comment.