Skip to content

Commit

Permalink
Refactor error messages + address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Huy Nguyen <[email protected]>
  • Loading branch information
huyaboo committed Apr 15, 2024
1 parent 4e13978 commit 28edd7f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Multiple Datasource] Add default icon in multi-selectable picker ([#6357](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6357))
- [Workspace] Add APIs to support plugin state in request ([#6303](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6303))
- [Workspace] Filter left nav menu items according to the current workspace ([#6234](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6234))
- [Multiple Datasource] Add support for Timeline ([#6385](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6385))
- [Multiple Datasource] Add multi data source support to Timeline ([#6385](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6385))
- [Multiple Datasource] Refactor data source selector component to include placeholder and add tests ([#6372](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6372))
- Replace control characters before logging ([#6402](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6402))
- [Dynamic Configurations] Improve dynamic configurations by adding cache and simplifying client fetch ([#6364](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6364))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ export function getTimelineRequestHandler({
});
} catch (e) {
if (e && e.body) {
const errorTitle =
e.body.attributes && e.body.attributes.title ? ` (${e.body.attributes.title})` : '';
const err = new Error(
`${i18n.translate('timeline.requestHandlerErrorTitle', {
defaultMessage: 'Timeline request error',
})}: ${e.body.title} ${e.body.message}`
})}${errorTitle}: ${e.body.message}`
);
err.stack = e.stack;
throw err;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export default function chainRunner(tlConfig) {
let sheet;

function throwWithCell(cell, exception) {
throw new Error(' in cell #' + (cell + 1) + ': ' + exception.message);
const e = new Error(exception.message);
e.name = `Expression parse error in cell #${cell + 1}`;
throw e;
}

// Invokes a modifier function, resolving arguments into series as needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const fetchDataSourceIdByName = async (
) => {
if (config.data_source_name) {
if (!getDataSourceEnabled().enabled) {
throw new Error('data_source_name cannot be used because data_source.enabled is false');
throw new Error('To query from multiple data sources, first enable the data sources feature');
}

const dataSources = await client.find<DataSourceAttributes>({
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/vis_type_timeline/server/routes/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ export function runRoute(
} else {
return response.internalError({
body: {
message: err.toString(),
attributes: {
title: err.name,
},
message: err.message,
},
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/vis_type_timeline/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ export interface OpenSearchFunctionConfig {
index: string | null;
timefield: string | null;
kibana: boolean | null;
opensearchDashboards: boolean | null;
/**
* @deprecated The interval picker should be used instead
* @deprecated This property should not be set in the Timeline expression. Users should use the interval picker React component instead
*/
interval: string | null;
data_source_name?: string | null;
Expand Down

0 comments on commit 28edd7f

Please sign in to comment.