Skip to content

Commit

Permalink
feat(client): use alert only for custom provider error
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellacosse committed Apr 22, 2024
1 parent 72083af commit 8abc909
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions client/src/www/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ export class App {
};
} else if (error instanceof errors.SessionConfigError) {
toastMessage = error.message;
} else if (error instanceof errors.SessionProviderError) {
return alert(error.message);
} else {
const hasErrorDetails = Boolean(error.message || error.cause);
toastMessage = this.localize('error-unexpected');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function parseShadowsocksSessionConfigJson(responseBody: string): ShadowsocksSes
const responseJson = JSON.parse(responseBody);

if ('error' in responseJson) {
throw new errors.SessionConfigError(responseJson.error.message);
throw new errors.SessionProviderError(responseJson.error.message);
}

const {method, password, server, server_port, prefix} = responseJson;
Expand Down
6 changes: 6 additions & 0 deletions client/src/www/model/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export class SessionConfigError extends CustomError {
}
}

export class SessionProviderError extends CustomError {
constructor(message: string) {
super(message);
}
}

export class ServerAccessKeyInvalid extends CustomError {
constructor(message: string, options?: {cause?: Error}) {
super(message, options);
Expand Down

0 comments on commit 8abc909

Please sign in to comment.