Error handling in collection hooks. #98
-
I'm trying to upload to a DigitalOcean spaces instance and I'm implementing the recommended hooks as specified in the documentation. https://payloadcms.com/docs/production/deployment I've implemented an upload hook (see attached) but I've got two comments.
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 11 replies
-
Also, could we re-export the collection hooks from |
Beta Was this translation helpful? Give feedback.
-
Sorry one more question/bug. I'm altering the filename as suggested. But the URL that's being returned is prepended with /media/images. For example: /media/images/https://brightvision.fra1.digitaloceanspaces.com.cdn.digitaloceanspaces.com/contact-image-10-8.jpg
|
Beta Was this translation helpful? Give feedback.
-
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:
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
You're right - the |
Beta Was this translation helpful? Give feedback.
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:
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 withinpayload/errors
which can be leveraged if you want for status codes, etc. but you could also just throw any error you want.