throw custom ValidationError

contains an message formatter, displaying all messages concatinated.
This commit is contained in:
Thomas Ruoff
2020-09-15 23:38:13 +02:00
parent e3a9da6efa
commit 00d30a4459
2 changed files with 27 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import {
loadBookingData,
storeBookingData,
} from '../../../helpers/storage'
import { ValidationError } from './validationError'
interface WizardFormData {
startDate: string
@@ -163,7 +164,7 @@ async function createBooking(formData: WizardFormData) {
if (response.status === 400) {
const error = await response.json()
throw Error(error.message)
throw new ValidationError(error.errors)
}
if (!response.ok) {