Skip to content

Commit

Permalink
catchign right code
Browse files Browse the repository at this point in the history
Signed-off-by: abbyhu2000 <[email protected]>
  • Loading branch information
abbyhu2000 committed Aug 29, 2024
1 parent 4dc2f7e commit b3543a7
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/core/public/http/intercept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export async function interceptResponse(
checkHalt(controller, error);

if (!interceptor.responseError) {
console.log('interceptor.responseError', error);

Check failure on line 118 in src/core/public/http/intercept.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected console statement

Check failure on line 118 in src/core/public/http/intercept.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected console statement
throw error;
}

Expand Down
5 changes: 5 additions & 0 deletions src/plugins/data/common/data_frames/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ export interface IDataFrameResponse extends SearchResponse<any> {
took: number;
}

export interface IDataFrameResponseError {
status: number;
message: string;
}

export interface IDataFrameError extends IDataFrameResponse {
error: Error;
}
3 changes: 3 additions & 0 deletions src/plugins/data/public/search/fetch/handle_response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import { getNotifications } from '../../services';
import { SearchRequest } from '..';

export function handleResponse(request: SearchRequest, response: SearchResponse<any>) {
if (response.cakecakecakecakecake) {
console.log('cakecakecakecakecake', response);

Check failure on line 42 in src/plugins/data/public/search/fetch/handle_response.tsx

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected console statement

Check failure on line 42 in src/plugins/data/public/search/fetch/handle_response.tsx

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected console statement
}
if (response.timed_out) {
getNotifications().toasts.addWarning({
title: i18n.translate('data.search.searchSource.fetch.requestTimedOutNotificationMessage', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ export const useSearch = (services: DiscoverViewServices) => {
rows: [],
});

console.log('error', error);

Check failure on line 229 in src/plugins/discover/public/application/view_components/utils/use_search.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected console statement

Check failure on line 229 in src/plugins/discover/public/application/view_components/utils/use_search.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected console statement

data.search.showError(error as Error);
} finally {
initalSearchComplete.current = true;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/query_enhancements/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ export const fetch = (context: EnhancedFetchContext, query: Query, aggConfig?: Q
body,
signal,
})
).pipe(
catchError((error) => {
console.log('fetch error', error.message);

Check failure on line 140 in src/plugins/query_enhancements/common/utils.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected console statement

Check failure on line 140 in src/plugins/query_enhancements/common/utils.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected console statement
// Handle the error as needed, e.g., rethrow, return a default value, etc.
throw error; // Rethrow the error if you want it to propagate
})
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class PPLSearchInterceptor extends SearchInterceptor {

return fetch(context, query, this.getAggConfig(searchRequest, query)).pipe(
catchError((error) => {
console.log('search interceptor error', error);

Check failure on line 57 in src/plugins/query_enhancements/public/search/ppl_search_interceptor.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected console statement

Check failure on line 57 in src/plugins/query_enhancements/public/search/ppl_search_interceptor.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected console statement
return throwError(error);
})
);
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/query_enhancements/server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ISearchStrategy } from '../../../data/server';
import { API, SEARCH_STRATEGY } from '../../common';
import { registerQueryAssistRoutes } from './query_assist';
import { registerDataSourceConnectionsRoutes } from './data_source_connection';
import { instance } from '../../../console/public/application/contexts/editor_context/editor_registry';

Check failure on line 18 in src/plugins/query_enhancements/server/routes/index.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected path "../../../console/public/application/contexts/editor_context/editor_registry" imported in restricted zone. Server code can not import from public, use a common directory

Check failure on line 18 in src/plugins/query_enhancements/server/routes/index.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected path "../../../console/public/application/contexts/editor_context/editor_registry" imported in restricted zone. Plugins may only import from top-level public and server modules

Check failure on line 18 in src/plugins/query_enhancements/server/routes/index.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected path "../../../console/public/application/contexts/editor_context/editor_registry" imported in restricted zone. Server code can not import from public, use a common directory

Check failure on line 18 in src/plugins/query_enhancements/server/routes/index.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected path "../../../console/public/application/contexts/editor_context/editor_registry" imported in restricted zone. Plugins may only import from top-level public and server modules

/**
* Defines a route for a specific search strategy.
Expand Down Expand Up @@ -85,10 +86,9 @@ function defineRoute(
);
return res.ok({ body: { ...queryRes } });
} catch (err) {
logger.error(err);
return res.custom({
statusCode: err.status ?? 500,
body: err,
statusCode: err.name,
body: err.message,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
DATA_FRAME_TYPES,
IDataFrameError,
IDataFrameResponse,
IDataFrameResponseError,
IDataFrameWithAggs,
IOpenSearchDashboardsSearchRequest,
Query,
Expand Down Expand Up @@ -41,7 +42,9 @@ export const pplSearchStrategyProvider = (
const rawResponse: any = await pplFacet.describeQuery(context, request);

if (!rawResponse.success) {
throw new Error(rawResponse.data.body);
const error = new Error(rawResponse.data.body);
error.name = rawResponse.data.status;
throw error;
}

const dataFrame = createDataFrame({
Expand Down Expand Up @@ -75,7 +78,7 @@ export const pplSearchStrategyProvider = (
took: rawResponse.took,
} as IDataFrameResponse;
} catch (e) {
logger.error(`pplSearchStrategy: ${e.message}`);
logger.error(`pplSearchStrategy: ${e}`);
if (usage) usage.trackError();
throw e;
}
Expand Down

0 comments on commit b3543a7

Please sign in to comment.