Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): use alert only for custom provider error #1991

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading