1

I want to delete "trace" from the exception response.

In my code i have something like this:

throw new \Magento\Framework\Exception\LocalizedException(__('You have already bought this item.'));

The response i get:

{"message": "You have already bought this item.",
"trace": "#0 /home/franco/magento2/vendor/magento/framework/Event/Invoker/InvokerDefault.php(73): Padi\\Cart\\Model\\Observer\\SetProduct->execute(Object(Magento\\Framework\\Event\\Observer))\n#1 /home/franco/magento2/vendor/magento/framework/Event/Invoker/InvokerDefault.php(61): Magento\\Framework\\Event\\Invoker\\InvokerDefault->_callObserverMethod(Object(Padi\\Cart\\Model\\Observer\\SetProduct), Object(Magento\\Framework\\Event\\Observer))\n#2 /home/franco/magento2/vendor/magento/framework/Event/Manager.php(66): Magento\\Framework\\Event\\Invoker\\InvokerDefault->dispatch(Array, Object(Magento\\Framework\\Event\\Observer))\n#3 /home/franco/magento2/var/generation/Magento/Framework/Event/Manager/Proxy.php(95): Magento\\Framework\\Event\\Manager->dispatch('sales_quote_ite...', Array)\n#4 /home/franco/magento2/vendor/magento/module-quote/Model/Quote/Item.php(431): Magento\\Framework\\Event\\Manager\\Proxy->dispatch('sales_quote_ite...', Array)\n#5 /home/franco/magento2/vendor/magento/module-quote/Mod"
..}

Thanks!

1 Answer 1

2

I assume you are looking at the AJAX response to an error on checkout. That trace should only appear when your store is in developer mode--set your site to production, and it will go away.

For more info about Magento 2 modes, see the official documentation: http://devdocs.magento.com/guides/v2.1/config-guide/bootstrap/magento-modes.html

1
  • Great!, yes i meant AJAX response, Thank you.
    – Franco
    Apr 7, 2017 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.