SupabaseS
Supabase6mo ago
Idris

Meaningless errors from supabase edge functions

In my edge function i throw a error like this:
        return new Response(
            JSON.stringify({
                error: {
                    http_code: errorCode,
                    message: errorMessage
                }
            }),
            {
                status: errorCode,
                headers: { ...corsHeaders, 'Content-Type': 'application/json' }
            }
        );


In my app I catch it
            const { data, error } = await supabase.functions.invoke('user-management/create-user', {
                body: requestData
            });

            if (error) {
                console.log(error);

but the errors are very meaningless its always FunctionsHttpError: Edge Function returned a non-2xx status code

How can I get a usefull error from the SDK, so the message of the error.|

The response does correctly contain the error if i look in the network tab
{
    "error": {
        "http_code": 500,
        "message": "A user with this email address has already been registered"
    }
}
Was this page helpful?