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 c4f9ded
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ export const useSearch = (services: DiscoverViewServices) => {
rows: [],
});

data.search.showError(error as Error);
console.log('error', error.body);

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.body || error) as Error);
} finally {
initalSearchComplete.current = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
*/

import { trimEnd } from 'lodash';
import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { formatTimePickerDate, Query } from '../../../data/common';
import {
DataPublicPluginStart,
Expand Down Expand Up @@ -52,11 +51,7 @@ export class PPLSearchInterceptor extends SearchInterceptor {

const query = this.buildQuery();

return fetch(context, query, this.getAggConfig(searchRequest, query)).pipe(
catchError((error) => {
return throwError(error);
})
);
return fetch(context, query, this.getAggConfig(searchRequest, query));
}

public search(request: IOpenSearchDashboardsSearchRequest, options: ISearchOptions) {
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

/**
* 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 c4f9ded

Please sign in to comment.