File tree Expand file tree Collapse file tree 3 files changed +53
-1
lines changed
Assets/Plugins/Web3AuthSDK Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Original file line number Diff line number Diff line change 1+ enum ErrorCode
2+ {
3+ NOUSERFOUND ,
4+ ENCODING_ERROR ,
5+ DECODING_ERROR ,
6+ RUNTIME_ERROR ,
7+ APP_CANCELLED ,
8+ SOMETHING_WENT_WRONG ,
9+ }
10+ sealed class Web3AuthError
11+ {
12+ public static string getError ( ErrorCode errorCode )
13+ {
14+ switch ( errorCode )
15+ {
16+ case ErrorCode . NOUSERFOUND :
17+ return "No user found, please login again!" ;
18+ case ErrorCode . ENCODING_ERROR :
19+ return "Encoding Error" ;
20+ case ErrorCode . DECODING_ERROR :
21+ return "Decoding Error" ;
22+ case ErrorCode . SOMETHING_WENT_WRONG :
23+ return "Something went wrong!" ;
24+ case ErrorCode . RUNTIME_ERROR :
25+ return "Runtime Error" ;
26+ case ErrorCode . APP_CANCELLED :
27+ return "App Cancelled!" ;
28+
29+ }
30+ return "" ;
31+ }
32+ }
Original file line number Diff line number Diff line change @@ -418,16 +418,25 @@ private void sessionTimeOutAPI()
418418
419419 public string getPrivKey ( )
420420 {
421- return web3AuthOptions . useCoreKitKey . Value ? web3AuthResponse . coreKitKey : web3AuthResponse . privKey ;
421+ if ( web3AuthResponse == null )
422+ throw new Exception ( Web3AuthError . getError ( ErrorCode . NOUSERFOUND ) ) ;
423+
424+ return web3AuthOptions . useCoreKitKey . Value ? web3AuthResponse . coreKitKey : web3AuthResponse . privKey ;
422425 }
423426
424427 public string getEd25519PrivKey ( )
425428 {
429+ if ( web3AuthResponse == null )
430+ throw new Exception ( Web3AuthError . getError ( ErrorCode . NOUSERFOUND ) ) ;
431+
426432 return web3AuthOptions . useCoreKitKey . Value ? web3AuthResponse . coreKitEd25519PrivKey : web3AuthResponse . ed25519PrivKey ;
427433 }
428434
429435 public UserInfo getUserInfo ( )
430436 {
437+ if ( web3AuthResponse == null )
438+ throw new Exception ( Web3AuthError . getError ( ErrorCode . NOUSERFOUND ) ) ;
439+
431440 return web3AuthResponse . userInfo ;
432441 }
433442
You can’t perform that action at this time.
0 commit comments