Skip to content

Error handling in collection hooks. #98

Answered by jmikrut
richardvanbergen asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @richardvanbergen I love it. I'd be pumped to add this as a tutorial / guide for Payload. We have had this on our list to write about but haven't gotten to it yet.

Couple answers:

Is there any way to inform the use if something goes wrong?

Yes, just throw an error and the error's message will bubble up through the API(s). You should be able to then see it in a response. Give it a shot! We have APIError exposed within payload/errors which can be leveraged if you want for status codes, etc. but you could also just throw any error you want.

There may be a bug in regards to duplicate filenames, or possibly just a bad implementation on my part. The beforeChange hook doesn't pass the fil…

Replies: 3 comments 11 replies

Comment options

You must be logged in to vote
2 replies
@jmikrut
Comment options

@jmikrut
Comment options

Comment options

You must be logged in to vote
3 replies
@jmikrut
Comment options

@richardvanbergen
Comment options

@jmikrut
Comment options

Comment options

You must be logged in to vote
6 replies
@richardvanbergen
Comment options

@jmikrut
Comment options

@richardvanbergen
Comment options

@jmikrut
Comment options

@DanRibbens
Comment options

Answer selected by DanRibbens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants