Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Re: Manually triggering function error for debugging purposes

Manually triggering function error for debugging purposes

tontinedev
Shopify Partner
8 0 4

Is there a way to manually throw an error in order to get access to debugging logs? I'm testing functions on a dev store with preview enabled, but the functions do not seem to be working after deploy and I can't figure out how to trigger an error report as described in the docs. I attempted to just immediately return an error with a custom error message from the main function but that doesn't seem to have done anything either. Any help here?

Reply 1 (1)

Nick_Wesselman
Shopify Staff
171 43 73

Hi @tontinedev --

Your best option in Rust for manually triggering an error is to use panic!. Then you can take an action which triggers your function (such as adding a product to cart or changing the quantity in the cart), which will then trigger an error report as described in the docs. The error report will show your function input and any other debug output you've printed to STDERR.

We are working on simpler ways of exposing debugging information to you, but this is your best approach in the mean time.

-Nick

Nick Wesselman | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog