Differentiate connectivity and auth related errors

Summary: Cleaning up login session and connectivity handling.

Reviewed By: passy

Differential Revision: D28795342

fbshipit-source-id: ddc659d681f730c7183f364d8924e5c680f8a418
This commit is contained in:
Anton Nikolaev
2021-06-02 11:29:11 -07:00
committed by Facebook GitHub Bot
parent fff489091e
commit b7d7326bae
2 changed files with 23 additions and 23 deletions

View File

@@ -9,6 +9,20 @@
import {InteractionReport} from 'flipper-plugin';
export function isAuthError(
err: any,
): err is UserNotSignedInError | UserUnauthorizedError {
return (
err instanceof UserNotSignedInError || err instanceof UserUnauthorizedError
);
}
export function isConnectivityOrAuthError(
err: any,
): err is ConnectivityError | UserNotSignedInError | UserUnauthorizedError {
return err instanceof ConnectivityError || isAuthError(err);
}
export class CancelledPromiseError extends Error {
constructor(msg: string) {
super(msg);
@@ -17,6 +31,14 @@ export class CancelledPromiseError extends Error {
name: 'CancelledPromiseError';
}
export class ConnectivityError extends Error {
constructor(msg: string) {
super(msg);
this.name = 'ConnectivityError';
}
name: 'ConnectivityError';
}
export class UserUnauthorizedError extends Error {
constructor(msg: string = 'User unauthorized.') {
super(msg);