pixelmund / svemix

The Full-Stack addition to SvelteKit. Write your server code inside svelte files, handle sessions, forms and SEO easily.
https://svemix.com
MIT License
337 stars 16 forks source link

Better Error-Handling #47

Open pixelmund opened 2 years ago

pixelmund commented 2 years ago

Describe the bug

Currently there is no easy way to throw errors inside loaders/actions. We should probably come up with an easy to use solution.

I have something like the following in my head:

<script context="module" ssr>
  import {  NotFoundError, HttpError } from "svemix/errors"
  export const loader = () => {
    throw new NotFoundError("User not found").
    throw new HttpError("Custom Error", { status: 401 });
   }
</script>

Which we could then make use of via instanceOf

Your Example Website or App

--

Steps to Reproduce the Bug or Issue

--

Expected behavior

--

Screenshots or Videos

No response

Platform

Additional context

Would make life easier