#How can I test my 500.astro error page?

3 messages · Page 1 of 1 (latest)

wet lagoon
#

I have an error page in src/pages/500.astro

Since the app is statically generated, I don't see how a 500 could be thrown, but I guess it could if Amazon S3 or CloudFront craps its pants.

I tried simulating an error with

---
throw new Error("Simulated error");
---

But this shows me the debug page with a stack trace.

Have any ideas on how I could test the render of my 500 page?

To be clear, I am NOT using SSR. I just thought it was best practice to have a 500 page no matter what.

rain gust
#

Hey! Hmmm, I too have no idea how this would ever be shown. If your provider threw a 500, you should see their 500 page and not yours 🤔

However, since it's just a page right, it's just a static page! Like a custom 404 page, so you can just test it..... Like any other page 😄 Just shove some stuff in and load up /500

You'd only need to throw errors if you wanted to check that an error redirected you to your 500 page, but since it's a static site nothing ever will.

Also fwiw 500s are thrown by servers, so if you're using say apache or express or.. i dunno django or smt to serve your pages then yeah there's a chance for a 500. But since it's static, I don't think you could ever even get redirected to a 500 page

Someone may swoop in and say otherwise, but I've certainly never seen a 500 error on a static site!

wet lagoon
#

Good points! I just found a setting on Amz CloudFront called 'custom error pages' where I'll throw in some code just in case a 500 is ever thrown!