Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Custom Exception Handling

Tyler King edited this page Sep 15, 2020 · 4 revisions

As of v13.0.0, the "login" page was removed and all internal exceptions were modified to be agnostic.

There are currently a few exceptions:

  • ApiException happens for API errors
  • MissingShopDomainException happens for bad sessions or direct access to app outside of Shopify
  • ChargeNotRecurringException happens when trying to apply usage charges to a one-time charge
  • ChargeNotRecurringOrOneTimeException happens when trying to modify a usage charge by mistake
  • SignatureVerificationException happens when the HMAC signature, proxy signature, or webhook signature does not validate

Without modification, in development, you will see the full exception stack from Laravel. On production, you will see Laravel's production handler for errors.

If you would like to handle these exceptions on your own, you can open app/Exceptions/Handler.php in your app and modify the render method:

    public function render($request, Throwable $exception)
    {
        if ($exception instanceof \Osiset\ShopifyApp\Exceptions\MissingShopDomainException) {
            return response()->view('errors.custom', [], 500);
        }

        // If you would like to capture all errors from this page
        // if ($exception instanceof \Osiset\ShopifyApp\Exceptions\BaseException) {
        //    return response()->view('errors.custom', [], 500);
        // }

        return parent::render($request, $exception);
    }

Now you are able to handle each exception, or all of them, in any manner you require.

Welcome to the wiki!

Please see the homepage for a list of relevant pages.

Clone this wiki locally