Skip to content

Commit a57d1bd

Browse files
committed
feat: add error codes
1 parent 70bf11c commit a57d1bd

7 files changed

Lines changed: 65 additions & 11 deletions

File tree

src/errors/AskCodebaseErrorCode.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
export enum AskCodebaseErrorCode {
2-
/** Success */
3-
E0000 = 0,
4-
/** Unkonwn error */
5-
E10001 = 10001,
6-
/** Access token expired */
7-
E10002 = 10002,
8-
/** API usage limit exceeded */
9-
E10003 = 10003,
10-
/** User is null */
11-
E10004 = 10004,
12-
}
2+
/** Success */
3+
E0000 = 0,
4+
/** Unkonwn error */
5+
E10001 = 10001,
6+
/** Access token expired */
7+
E10002 = 10002,
8+
/** API usage limit exceeded */
9+
E10003 = 10003,
10+
/** User is null */
11+
E10004 = 10004,
12+
/** Authentication error */
13+
E10005 = 10005,
14+
/** State is null */
15+
E10006 = 10006,
16+
/** Can't get github user by access token */
17+
E10007 = 10007,
18+
/** Can't get google user by access token */
19+
E10008 = 10008,
20+
}

src/errors/ErrorAuthentication.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { AskCodebaseError } from "./AskCodebaseError";
2+
import { AskCodebaseErrorCode } from "./AskCodebaseErrorCode";
3+
4+
export class ErrorAuthentication extends AskCodebaseError {
5+
public static code = AskCodebaseErrorCode.E10005;
6+
7+
constructor(message: string = "Authentication error.") {
8+
super(ErrorAuthentication.code, message);
9+
}
10+
}

src/errors/ErrorGithubUser.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { AskCodebaseError } from "./AskCodebaseError";
2+
import { AskCodebaseErrorCode } from "./AskCodebaseErrorCode";
3+
4+
export class ErrorGithubUser extends AskCodebaseError {
5+
public static code = AskCodebaseErrorCode.E10007;
6+
7+
constructor(message: string = "Authentication error.") {
8+
super(ErrorGithubUser.code, message);
9+
}
10+
}

src/errors/ErrorGoogleUser.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { AskCodebaseError } from "./AskCodebaseError";
2+
import { AskCodebaseErrorCode } from "./AskCodebaseErrorCode";
3+
4+
export class ErrorGoogleUser extends AskCodebaseError {
5+
public static code = AskCodebaseErrorCode.E10008;
6+
7+
constructor(message: string = "Authentication error.") {
8+
super(ErrorGoogleUser.code, message);
9+
}
10+
}

src/errors/ErrorStateNull.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { AskCodebaseError } from "./AskCodebaseError";
2+
import { AskCodebaseErrorCode } from "./AskCodebaseErrorCode";
3+
4+
export class ErrorStateNull extends AskCodebaseError {
5+
public static code = AskCodebaseErrorCode.E10006;
6+
7+
constructor(message: string = "State is null") {
8+
super(ErrorStateNull.code, message);
9+
}
10+
}

src/errors/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ export * from "./ErrorTokenExpired";
44
export * from "./ErrorApiUsageExceeded";
55
export * from "./ErrorUserNull";
66
export * from "./ErrorNone";
7+
export * from "./ErrorGithubUser";
8+
export * from "./ErrorGoogleUser";
9+
export * from "./ErrorStateNull";
10+
export * from "./ErrorAuthentication";

sui.log.2023-07-27

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2023-07-27T11:21:07.327704Z INFO sui::client_commands: 0xcd0247d0b67e53dde69b285e7a748e3dc390e8a5244eb9dd9c5c53d95e4cf0aa
2+
2023-07-27T11:22:07.379793Z INFO sui::client_commands: 0xcd0247d0b67e53dde69b285e7a748e3dc390e8a5244eb9dd9c5c53d95e4cf0aa

0 commit comments

Comments
 (0)