refactor: better errors (#590)

* refactor: improve error messages from server
This commit is contained in:
Carlos Valente
2023-11-14 21:54:56 +01:00
committed by GitHub
parent a41fe8806b
commit 1ca3b9c134
9 changed files with 26 additions and 29 deletions
-1
View File
@@ -11,7 +11,6 @@ export function maybeAxiosError(error: unknown) {
const statusText = (error as AxiosError).response?.statusText ?? '';
let data = (error as AxiosError).response?.data ?? '';
if (typeof data === 'object') {
// TODO: use error instead, when migrated
if ('message' in data) {
data = JSON.stringify(data.message);
} else {
@@ -100,7 +100,7 @@ export const useEventAction = () => {
// @ts-expect-error -- we know that the object is well formed now
await _addEventMutation.mutateAsync(newEvent);
} catch (error) {
logAxiosError('Error fetching data', error);
logAxiosError('Failed adding event', error);
}
},
[_addEventMutation, defaultPublic, queryClient, startTimeIsLastEnd],