mirror of
https://github.com/pockethost/pockethost.git
synced 2025-07-05 20:32:29 +00:00
15 lines
343 B
TypeScript
15 lines
343 B
TypeScript
import { client } from '$src/pocketbase-client'
|
|
|
|
export type FormErrorHandler = (value: string) => void
|
|
|
|
export const handleFormError = (e: Error, setError?: FormErrorHandler) => {
|
|
const { parseError } = client()
|
|
|
|
if (setError) {
|
|
const message = parseError(e)[0]
|
|
setError(message || 'Unknown message')
|
|
} else {
|
|
throw e
|
|
}
|
|
}
|