Return Error from Edge Function

Hello,

I'm trying to return a custom error from an edge function.

You can see in the screenshot attached I can return the response as a 500. However, I don't understand how to throw an error so that the supabase invoke function catches the error (and then populates error instead of data)

I'm also pretty confused because if I try to just throw new Error('some error') instead of returning a response, I get a CORS Policy block. So it seems like I must return a response with my CORS headers, but then I'm not sure how to return an error at that point?

I'm also a total Deno noob, so I may be missing something really obvious here.
unknown.png
Was this page helpful?