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:
committed by
Facebook GitHub Bot
parent
fff489091e
commit
b7d7326bae
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user