From 7143c793617f5512c256fa64e2931e1a8d3b6c8b Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Wed, 31 Jul 2024 04:09:19 -0700 Subject: [PATCH] Interngraph server error class Summary: We were losing the request body which meant that a clear request code could not be used, by adding an error subclass we can check for it in catch clause Reviewed By: passy Differential Revision: D59961466 fbshipit-source-id: 490e831759d90d4e83153daf4b7a4baa5b38dbdb --- desktop/flipper-common/src/index.tsx | 1 + desktop/flipper-common/src/utils/errors.tsx | 10 ++++++++++ desktop/flipper-plugin/src/index.tsx | 1 + 3 files changed, 12 insertions(+) diff --git a/desktop/flipper-common/src/index.tsx b/desktop/flipper-common/src/index.tsx index 26ed4ed6dfd..ec3d068b9a6 100644 --- a/desktop/flipper-common/src/index.tsx +++ b/desktop/flipper-common/src/index.tsx @@ -55,6 +55,7 @@ export { isError, isAuthError, FlipperServerDisconnectedError, + InternGraphServerError, FlipperServerTimeoutError, getStringFromErrorLike, getErrorFromErrorLike, diff --git a/desktop/flipper-common/src/utils/errors.tsx b/desktop/flipper-common/src/utils/errors.tsx index a85e84fddf5..b5ca46b9a3c 100644 --- a/desktop/flipper-common/src/utils/errors.tsx +++ b/desktop/flipper-common/src/utils/errors.tsx @@ -77,6 +77,16 @@ export class ConnectivityError extends Error { name: 'ConnectivityError'; } +export class InternGraphServerError extends Error { + body: any; + constructor(msg: string, body: any) { + super(msg); + this.name = 'InternGraphServerError'; + this.body = body; + } + name: 'InternGraphServerError'; +} + export class UserUnauthorizedError extends Error { constructor(msg: string = 'User unauthorized.') { super(msg); diff --git a/desktop/flipper-plugin/src/index.tsx b/desktop/flipper-plugin/src/index.tsx index 0852797788b..20c72bdb119 100644 --- a/desktop/flipper-plugin/src/index.tsx +++ b/desktop/flipper-plugin/src/index.tsx @@ -212,4 +212,5 @@ export { ServerAddOn, ServerAddOnPluginConnection, FlipperServerForServerAddOn, + InternGraphServerError, } from 'flipper-common';