fix: Reduce double reporting of errors

This commit is contained in:
Tom Moor
2020-12-21 21:10:25 -08:00
parent 7d44e1aeeb
commit ea57cef89c
4 changed files with 14 additions and 1 deletions

View File

@ -28,7 +28,6 @@ class UserDelete extends React.Component<Props> {
this.props.auth.logout();
} catch (error) {
this.props.ui.showToast(error.message);
throw error;
} finally {
this.isDeleting = false;
}

View File

@ -5,10 +5,12 @@ import stores from "stores";
import download from "./download";
import {
AuthorizationError,
BadRequestError,
NetworkError,
NotFoundError,
OfflineError,
RequestError,
ServiceUnavailableError,
UpdateRequiredError,
} from "./errors";
@ -141,6 +143,10 @@ class ApiClient {
throw new UpdateRequiredError(error.message);
}
if (response.status === 400) {
throw new BadRequestError(error.message);
}
if (response.status === 403) {
throw new AuthorizationError(error.message);
}
@ -149,6 +155,10 @@ class ApiClient {
throw new NotFoundError(error.message);
}
if (response.status === 503) {
throw new ServiceUnavailableError(error.message);
}
throw new RequestError(error.message);
};

View File

@ -2,8 +2,10 @@
import ExtendableError from "es6-error";
export class AuthorizationError extends ExtendableError {}
export class BadRequestError extends ExtendableError {}
export class NetworkError extends ExtendableError {}
export class NotFoundError extends ExtendableError {}
export class OfflineError extends ExtendableError {}
export class ServiceUnavailableError extends ExtendableError {}
export class RequestError extends ExtendableError {}
export class UpdateRequiredError extends ExtendableError {}

View File

@ -54,9 +54,11 @@
ignoreErrors: [
"ResizeObserver loop limit exceeded",
"AuthorizationError",
"BadRequestError",
"NetworkError",
"NotFoundError",
"OfflineError",
"ServiceUnavailableError",
"UpdateRequiredError",
"ChunkLoadError",
],