Skip to content

Commit

Permalink
intercept check file
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <[email protected]>
  • Loading branch information
ps48 committed Feb 28, 2024
1 parent 8fb7a7f commit 29bc671
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions public/glue_catalog_cache/intercept_utils.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
HttpInterceptorResponseError,
IHttpInterceptController,
} from '../../../../src/core/public';

export function interceptError(): any {
return (httpErrorResponse: HttpInterceptorResponseError, _: IHttpInterceptController) => {
if (
httpErrorResponse.response?.status === 401 &&
httpErrorResponse.fetchOptions.path === '/api/v1/configuration/account'
) {
console.log('hereeeeee! recieved 401 in status');
}
};
}
5 changes: 5 additions & 0 deletions public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '../../../src/core/public';
import { PLUGIN_NAME } from '../common/constants';
import { coreRefs } from './framework/core_refs';
import { interceptError } from './glue_catalog_cache/intercept_utils';
import { AppPluginStartDependencies, WorkbenchPluginSetup, WorkbenchPluginStart } from './types';

export class WorkbenchPlugin implements Plugin<WorkbenchPluginSetup, WorkbenchPluginStart> {
Expand Down Expand Up @@ -42,6 +43,10 @@ export class WorkbenchPlugin implements Plugin<WorkbenchPluginSetup, WorkbenchPl
coreRefs.application = core.application;
coreRefs.overlays = core.overlays;

core.http.intercept({
responseError: interceptError(),
});

return {};
}

Expand Down

0 comments on commit 29bc671

Please sign in to comment.