Skip to content

Commit

Permalink
clarify cause and details
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellacosse committed Apr 25, 2024
1 parent 6b2561b commit 368f1cb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
30 changes: 18 additions & 12 deletions client/src/www/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,37 +204,36 @@ export class App {
toastMessage = this.localize('error-connection-configuration');
buttonMessage = this.localize('error-details');
buttonHandler = () => {
this.showErrorDetailDialog(error);
this.showErrorCauseDialog(error);
};
} else if (error instanceof errors.SessionConfigFetchFailed) {
toastMessage = this.localize('error-connection-configuration-fetch');
buttonMessage = this.localize('error-details');
buttonHandler = () => {
this.showErrorDetailDialog(error);
this.showErrorCauseDialog(error);
};
} else if (error instanceof errors.ProxyConnectionFailure) {
toastMessage = this.localize('error-connection-proxy');
buttonMessage = this.localize('error-details');
buttonHandler = () => {
this.showErrorDetailDialog(error);
this.showErrorCauseDialog(error);
};
} else if (error instanceof errors.SessionConfigError) {
toastMessage = error.message;

if (error.cause) {
buttonMessage = this.localize('error-details');
buttonHandler = () => {
this.showErrorDetailDialog(error);
};
}
} else if (error instanceof errors.SessionProviderError) {
toastMessage = error.message;
buttonMessage = this.localize('error-details');
buttonHandler = () => {
this.showErrorDetailDialog(error);
};
} else {
const hasErrorDetails = Boolean(error.message || error.cause);
toastMessage = this.localize('error-unexpected');

if (hasErrorDetails) {
buttonMessage = this.localize('error-details');
buttonHandler = () => {
this.showErrorDetailDialog(error);
this.showErrorCauseDialog(error);
};
}
}
Expand Down Expand Up @@ -580,7 +579,7 @@ export class App {
return new Promise<boolean>(resolve => resolve(confirm(message)));
}

private showErrorDetailDialog(error: Error) {
private showErrorCauseDialog(error: Error) {
let message = error.toString();

if (error.cause) {
Expand All @@ -592,6 +591,13 @@ export class App {
return alert(message);
}

private showErrorDetailDialog(error: errors.SessionProviderError) {
if (!error.details) return;

// Temporarily use window.alert here
return alert(error.details);
}

//#endregion UI dialogs

// Helpers:
Expand Down
10 changes: 10 additions & 0 deletions client/src/www/model/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export class SessionConfigError extends CustomError {
}
}

export class SessionProviderError extends CustomError {
details: string | undefined;

constructor(message: string, options?: {details?: string}) {
super(message);

this.details = options && options.details;
}
}

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

0 comments on commit 368f1cb

Please sign in to comment.