Skip to content

Commit

Permalink
feat: proper err message for regex
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-guan committed Jul 16, 2023
1 parent a144027 commit 7cb78f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pages/s/[id]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Textarea from 'primevue/textarea'
import Card from 'primevue/card'
import { useToast } from 'primevue/usetoast'
import { TRPCClientError } from '@trpc/client'
import type { SurveyResponseSchema } from '~/shared/survey'
definePageMeta({
Expand Down Expand Up @@ -84,6 +85,12 @@ async function submit() {
}
catch (err) {
console.error(err)
if (err instanceof TRPCClientError) {
toast.add({
severity: 'error',
summary: err.message,
})
}
}
finally {
pending.value = false
Expand Down
9 changes: 9 additions & 0 deletions pages/thanks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Button from 'primevue/button'
import InputText from 'primevue/inputtext'
import ProgressBar from 'primevue/progressbar'
import { useToast } from 'primevue/usetoast'
import { TRPCClientError } from '@trpc/client'
definePageMeta({
middleware: ['participant'],
Expand Down Expand Up @@ -85,6 +86,14 @@ async function create() {
}
catch (err) {
console.error(err)
if (err instanceof TRPCClientError) {
if (err.data.code === 'BAD_REQUEST') {
toast.add({
severity: 'error',
summary: 'Please enter a valid NRIC or phone number!',
})
}
}
}
finally {
formData.pending = false
Expand Down

0 comments on commit 7cb78f9

Please sign in to comment.