Skip to content

Commit a0f70a0

Browse files
committed
code updated.
1 parent fcff429 commit a0f70a0

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

Assets/Plugins/Web3AuthSDK/Types/Web3AuthError.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/Web3AuthSDK/Web3Auth.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)