MCPcopy Index your code
hub / github.com/0010aor/FlashNotes / handleError

Function handleError

frontend/src/utils.ts:60–73  ·  view source on GitHub ↗
(
  err: ApiError,
  showToast: (title: string, message: string, type: string) => void,
)

Source from the content-addressed store, hash-verified

58}
59
60export const handleError = (
61 err: ApiError,
62 showToast: (title: string, message: string, type: string) => void,
63) => {
64 const errDetail = (err.body as { detail?: string | { msg: string }[] })?.detail
65 let errorMessage = t('general.errors.default')
66
67 if (typeof errDetail === 'string') {
68 errorMessage = errDetail
69 } else if (Array.isArray(errDetail) && errDetail.length > 0) {
70 errorMessage = errDetail[0].msg
71 }
72 showToast(t('general.errors.error'), errorMessage, 'error')
73}

Callers

nothing calls this directly

Calls 1

tFunction · 0.85

Tested by

no test coverage detected