Skip to content

Commit

Permalink
add more catches
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemumma committed Jan 14, 2025
1 parent 4193562 commit a29e364
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions snuba/admin/static/clickhouse_queries/query_display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,27 @@ function QueryDisplay(props: {
}

function handleQueryError(error: any) {
const lines = error.error.split("\n");
if (lines.length > 1) {
setQueryError({
title: lines[0],
body: lines.slice(1).join("\n"),
})
} else {
setQueryError({
title: error,
body: ""
});
try {
// this block assumes that the error is an object with an error property,
// if its not it will be caught by the catch block
const lines = error.error.split("\n");
if (lines.length > 1) {
setQueryError({
title: lines[0],
body: lines.slice(1).join("\n"),
})
} else {
setQueryError({
title: "Error",
body: lines[0]
});
}
} catch (e) {
if (typeof error === "object") {
setQueryError({ title: "Error", body: JSON.stringify(error) });
} else {
setQueryError({ title: "Error", body: error.toString() });
}
}
}

Expand Down

0 comments on commit a29e364

Please sign in to comment.