Base class for every error @supabase/server produces.
Catch this to handle anything originating from this library, regardless of whether it's an EnvError or an AuthError:
Always `"@supabase/server"`.
HTTP status code appropriate for this error.
Machine-readable error code.
Actionable next step, when one applies.
Documentation URL for this error's `code`.
Structured, non-sensitive diagnostics — accepted auth modes, which credential headers were present, configured key *names*, JWT header fields. Never key values or token payloads.
import { SupabaseServerError } from '@supabase/server'
try {
const supabase = createAdminClient()
} catch (e) {
if (e instanceof SupabaseServerError) {
console.error(e.code, e.message, e.hint, e.docs)
return Response.json(e.toJSON(), { status: e.status })
}
throw e
}