Handle validation error toasts

This commit is contained in:
Mel O'Hagan 2022-07-20 10:46:24 +01:00
parent 40ef719f2f
commit ec586191e7
1 changed files with 8 additions and 1 deletions

View File

@ -58,9 +58,16 @@ export const API = createAPIClient({
} }
} }
if (!ignore) { if (!ignore) {
const validationErrors = error?.json?.validationErrors
if (validationErrors) {
for (let field in validationErrors) {
notificationStore.actions.error(`${field} ${validationErrors[field]}`)
}
} else {
notificationStore.actions.error(message) notificationStore.actions.error(message)
} }
} }
}
// Log all errors to console // Log all errors to console
console.warn(`[Client] HTTP ${status} on ${method}:${url}\n\t${message}`) console.warn(`[Client] HTTP ${status} on ${method}:${url}\n\t${message}`)