Error handling management

Hello there,

We need to have a way to handle specific errors like
400 - Bad Request
401 - Unauthorized
404 - Not Found
429 - Too Many Request
500, 502, 503, 504 - Server Errors

How can we achieve this properly ?

The only way we found for now is to check the err message like :

err.message !== 'No documents were returned' &&
          err.message !== 'An invalid API response was returned'

We do need to have something robust about rate limiting, not founded entities, server error like this week when AWS was down and so Prismic ...

Thanks a lot,

Regards,

Antonin

Hello Simon,

Thanks for reaching out to us.

Here are the error classes the package throws with @prismicio/client, prismic-client/src/errors at master · prismicio/prismic-client · GitHub. You can use them to identify more precisely what happened.

I hope I have answered your questions. Let me know if you have any further questions.

Thanks,
Priyanka