Skip to content

Commit

Permalink
Handle Internal Server Error
Browse files Browse the repository at this point in the history
Signed-off-by: Suchit Sahoo <[email protected]>
  • Loading branch information
LDrago27 committed Oct 11, 2024
1 parent 9eae148 commit d1fceaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/plugins/data/server/dql_telemetry/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function registerDqlTelemetryRoute(
},
async (context, request, response) => {
const [{ savedObjects }] = await getStartServices();
const internalRepository = savedObjects.createScopedRepository(request);

const {
body: { opt_in: optIn },
Expand All @@ -56,11 +55,12 @@ export function registerDqlTelemetryRoute(
const counterName = optIn ? 'optInCount' : 'optOutCount';

try {
const internalRepository = savedObjects.createScopedRepository(request);

Check warning on line 58 in src/plugins/data/server/dql_telemetry/route.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/server/dql_telemetry/route.ts#L58

Added line #L58 was not covered by tests
await internalRepository.incrementCounter('dql-telemetry', 'dql-telemetry', counterName);
} catch (error) {
logger.warn(`Unable to increment counter: ${error}`);
return response.customError({
statusCode: error.status,
statusCode: error.status || 403,
body: {
message: 'Something went wrong',
attributes: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export const vegaVisualizationClientWrapper: SavedObjectsClientWrapperFactory =
) => {
const vegaSpec = extractVegaSpecFromAttributes(attributes);
if (type !== 'visualization' || vegaSpec === undefined || !getDataSourceEnabled().enabled) {
return await wrapperOptions.client.create(type, attributes, options);
try {
return await wrapperOptions.client.create(type, attributes, options);
} catch (ex) {
throw SavedObjectsErrorHelpers.createUnsupportedTypeError(type);

Check warning on line 34 in src/plugins/vis_type_vega/server/vega_visualization_client_wrapper.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/vis_type_vega/server/vega_visualization_client_wrapper.ts#L34

Added line #L34 was not covered by tests
}
}
const dataSourceNamesSet = extractDataSourceNamesInVegaSpec(vegaSpec);

Expand Down

0 comments on commit d1fceaa

Please sign in to comment.