Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: axios error display #1133

Merged
merged 2 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions querybook/webapp/__tests__/ui/__snapshots__/Table.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ exports[`matches enzyme snapshots matches snapshot 1`] = `
"Header": undefined,
"Pivot": undefined,
"PivotValue": undefined,
"Placeholder": undefined,
"aggregate": undefined,
"className": "",
"filterAll": false,
Expand All @@ -47,7 +46,6 @@ exports[`matches enzyme snapshots matches snapshot 1`] = `
"getProps": [Function],
"headerClassName": "",
"headerStyle": Object {},
"minResizeWidth": 11,
"minWidth": 100,
"resizable": undefined,
"show": true,
Expand Down Expand Up @@ -77,7 +75,6 @@ exports[`matches enzyme snapshots matches snapshot 1`] = `
defaultExpanded={Object {}}
defaultFilterMethod={[Function]}
defaultFiltered={Array []}
defaultPage={0}
defaultPageSize={20}
defaultResized={Array []}
defaultSortDesc={false}
Expand Down Expand Up @@ -126,7 +123,6 @@ exports[`matches enzyme snapshots matches snapshot 1`] = `
ofText="of"
onFetchData={[Function]}
originalKey="_original"
pageJumpText="jump to page"
pageSizeOptions={
Array [
5,
Expand All @@ -144,7 +140,6 @@ exports[`matches enzyme snapshots matches snapshot 1`] = `
previousText="Previous"
resizable={true}
resolveData={[Function]}
rowsSelectorText="rows per page"
rowsText="rows"
showPageJump={true}
showPageSizeOptions={true}
Expand Down Expand Up @@ -1074,7 +1069,6 @@ exports[`matches test renderer snapshot serializes the styles 1`] = `
className="-pageJump"
>
<input
aria-label="jump to page"
onBlur={[Function]}
onChange={[Function]}
onKeyPress={[Function]}
Expand All @@ -1095,39 +1089,50 @@ exports[`matches test renderer snapshot serializes the styles 1`] = `
className="select-wrap -pageSizeOptions"
>
<select
aria-label="rows per page"
onChange={[Function]}
value={20}
>
<option
value={5}
>
5 rows
5

rows
</option>
<option
value={10}
>
10 rows
10

rows
</option>
<option
value={20}
>
20 rows
20

rows
</option>
<option
value={25}
>
25 rows
25

rows
</option>
<option
value={50}
>
50 rows
50

rows
</option>
<option
value={100}
>
100 rows
100

rows
</option>
</select>
</span>
Expand Down
6 changes: 2 additions & 4 deletions querybook/webapp/lib/utils/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AxiosError } from 'axios';
import { isObject } from 'lodash';
import moment from 'moment';

import { formatDuration, generateFormattedDate } from './datetime';
Expand All @@ -9,10 +10,7 @@ export function formatError(error: any): string {
return error;
}

const isErrorObject =
error != null &&
typeof error === 'object' &&
error.constructor === Error;
const isErrorObject = isObject(error);
if (isErrorObject) {
if (isAxiosError(error)) {
if (isAxiosErrorWithMessage(error)) {
Expand Down