Skip to content

Commit 78be87d

Browse files
committed
feat(support error from app): support throw the error message form the app
1 parent 11760fb commit 78be87d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/provider.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,10 @@ export class Provider implements IProvider {
277277
this
278278
)
279279
} catch (e) {
280-
console.error('[AnyWeb] Error to sendTransaction', e)
281-
return e
280+
throw new ProviderRpcError(
281+
ProviderErrorCode.SendTransactionError,
282+
'Error to sendTransaction: ' + e
283+
)
282284
}
283285
case 'anyweb_importAccount':
284286
try {
@@ -293,8 +295,10 @@ export class Provider implements IProvider {
293295
this
294296
)
295297
} catch (e) {
296-
console.error('[AnyWeb] Error to import Address', e)
297-
return e
298+
throw new ProviderRpcError(
299+
ProviderErrorCode.ImportAddressError,
300+
'Error to import Address: ' + e
301+
)
298302
}
299303
case 'anyweb_version':
300304
return config.version

src/utils/common.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ export enum ProviderErrorCode {
367367
ChainDisconnected = 4901,
368368
SDKNotReady = 5000,
369369
ParamsError = 6000,
370+
RequestError = 7000,
371+
SendTransactionError = 7001,
372+
ImportAddressError = 7002,
370373
}
371374

372375
export class ProviderRpcError extends Error implements IProviderRpcError {

0 commit comments

Comments
 (0)