36

The call Mage::throwException is used to throw exceptions of the specific Mage_Core_Exception variety. These are generally used to present error messages to the end user. For examples of this, do a quick search for Mage::throwException in the Mage_Checkout module, you'll find many instances where the error message is actually being translated before it's ...


19

The easiest way to start logging your exceptions would be to inject the Psr\Log\LoggerInterface into your class's constructor: private $logger; public function __construct(\Psr\Log\LoggerInterface $logger) { $this->logger = $logger; } And then in your catch statement: public function doSomething() { try { /* Some logic that could throw ...


18

I just recently came across this same situation after migrating from Magento 1.6.1.0 to 2.1.4 and hope my answer can be of assistance. The problem came from deleting multiple stores 96 of them to be exact. I tried all the other answers here but was still getting the same error. The fix for me was removing the old store data from inside of the "...


16

You've done the hard part, finding out how often they're used :) tl;dr: IMHO, you should use Mage::throwException most often, falling back to Mage::exception when you need to raise an exception type from outside of the scope of your module, if for no other reason than the session messaging ability and the fact that you don't have to type throw new in front ...


13

You need to run following query in your database, and then try to open website. SET FOREIGN_KEY_CHECKS=0; UPDATE `store` SET store_id = 0 WHERE code='admin'; UPDATE `store_group` SET group_id = 0 WHERE name='Default'; UPDATE `store_website` SET website_id = 0 WHERE code='admin'; UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='...


11

Delete records from 'url_rewrite' table where "entity_type" is "category". run php bin/magento indexer:reindex


11

I search some more things on this and finaly found my solution, I need to just change the observer code like this. app\code\Vendor\Extension\Observer\RemovecartbeforeObserver.php use Magento\Framework\Event\ObserverInterface; class RemovecartbeforeObserver implements ObserverInterface { protected $messageManager; protected $_responseFactory; ...


11

I thought I could catch that using generic php Exception class, but it seems we need to use the concrete throwed Exception Using this code, then the try/catch block works try { $product = $productRepository->get($sku); } catch (\Magento\Framework\Exception\NoSuchEntityException $e){ $product = false; }


10

It is quite famous error. It means that somewhere you save object of SimpleXMLElement class (or its child) to the session. In your particular case it is Mage_Core_Model_Config_Element class. When script ends his work, php tries to save all objects from $_SESSION array to the session file and tries to serialize $_SESSION array. Unfortunately, ...


10

Exception errors are stored as number named files in var/report/ except if the directory permissions are so messed up that Magento either cannot write there or tries to store its cache in the system /tmp directory. Use an sftp client to locate and read the files in the var/report/ directory. The hack used in Magento 1.x to show the stack trace on screen ...


9

I would say this is your error: PayPal NVP CURL connection error #28: Operation timed out after 30000 milliseconds with 0 bytes received And I would interpret as PayPal is not reachable. Maybe they were down? Or is this an repeating error? Try to fire a request to the API if something comes back everything is fine, if not, maybe your admin blocks *....


9

Try with below code, public function senderEmail($type = null, $storeId = null) { $sender ['email'] = $this->scopeConfig->getValue( self::SENDER_EMAIL, ScopeInterface::SCOPE_STORE, $storeId ); $sender['name'] =...


8

There has been an error processing your request Exception printing is disabled by default for security reasons. Error log record number: [ugly long number here] This is a way too often asked question, so this is one of those WIKI type items. Your system has run into a problem so egregious that PHP throws a stack trace. It breaks PCI-DSS rules to ...


8

This didn't seem as readily accessible as I thought it should be from some searching I did, so I'm posting up a question question/answer for future reference. Thrown Exceptions You can enable email notifications for exceptions that are thrown using errors/local.xml. You can copy your errors/local.xml.template to `errors/local.xml' and drop in the email ...


7

Emailing every exception will probably result in a LOT of mail. It might be a better option to just log the exceptions to the exception log and mail that once a day to yourself using a cronjob in linux 0 23 * * * /usr/lib/sendmail email@domain.com < /home/shop.com/www/var/log/exception.log And optionally cleaning it up after you've mailed it 0 23 * * *...


7

My version override based of method getItemRenderer of Magento\Checkout\Block\Cart\AbstractCart, used variable OverriddenTemplates. file vendor/module/view/frontend/layout/checkout_cart_item_renderers.xml <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration....


7

Magento2 has different types of Exception handlers, for example: StateException InputException InvalidEmailOrPasswordException MailException NotFoundException ValidatorException Etc. All handler types and their classes exist in \vendor\magento\framework\Exception. You need to choose the relevant Exception handler for your requirements and use that.


6

Are there any rules for how I should do it? Yes. If you take a look at app/Mage.php in the exception() method, you will see that it looks for an exception that matches the pattern $module . '_Exception, for example: YourCompany_YourModule_Exception: /** * Return new exception by module to be thrown * * @param string $module * @param string $message * @...


6

Please run the below commands and try again: php bin/magento module:disable Temando_Shipping rm -rf var/cache/ generated/code pub/static/frontend pub/static/adminhtml php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f php bin/magento setup:di:compile sudo chmod -R 777 var/ pub/ generated/


5

The throw happens when there are elements in the $this->_importErrors array. These errors are not cause by throwing exceptions but by checks like making sure we have enough rows to import. if ($this->_importErrors) { $error = Mage::helper('shipping')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this-&...


5

Good question +1 Did some research and tests after a good point in the direction after my discussion with @mpw on my first answer. I partly misunderstood it the first time. Will add some code to clarify so others understand the issue better. A note before take off I never had such problems until this came up. Developing in Magento with developer mode ...


5

I suspect what you are seeing is related to how the FrontController handles errors. Catch - FrontController calling getDefaultResult } catch (\Exception $e) { $this->handleException($e); $result = $actionInstance->getDefaultResult(); } Redirect - AbstractAction redirecting to base URL public function getDefaultResult() { $...


5

Try to get collection following way: $productCollection = $this->agencyProductFactory ->create()->getCollection()->addFieldToFilter('zw_agency_product_id', 1);


4

You can use the Magento Hackthon Logger for this job: https://github.com/firegento/firegento-logger/ It is not the question, but there are extensions for the extension: https://github.com/magento-hackathon/LoggerSentry/ What I want to say: It is easy to implement your own "Writer" :-)


4

The error's right there for you to see Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails PHP is telling you it can't perform the SQL you asked it to perform, because a SQL foreign key constraint failed. If you look at the details of the error, you know this is on the table catalog_product_super_link. ...


4

It looks like the catalog_product_flat tables became corrupted. Doing repairs with mysqlcheck and phpmyadmin didn't work because they are not supported by InnoDB. To work around this issue, first backup your database. Then run the following statement on your database to change the engine from InnoDB to MyISAM. ALTER TABLE catalog_product_flat ENGINE = ...


4

The message says that you use invalid block somewhere in the code. Stack trace log is cut. It is a PHP fault. How to fix it in Magento refer to this answer https://stackoverflow.com/a/12358464/2720986 Check the trace log near this line #2 /chroot/home/vourwebsitec/ourwebsite.com/html/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout-&...


4

you can execute Magento2 commands with the '-vvv' switch to get the debug output. bin/magento batch:creteo -vvv Also, if your class is in a namespace and you did not import the \Exception class (just assuming, can't see that in your example), it has to be \Exception in the catch block. Otherwise it will be searched for in your current namespace /** * {@...


4

I can't guarantee that it's the best solution but when reading the source code of Magento 2 core files most modules do it this way: Create a new folder called Exception in your module's directory. Add a new PHP class (e.g. CustomResponseException) to this folder The class CustomResponseException should extend the LocalizedException class. This class extends ...


4

Regarding the debug file So the messages like this main.DEBUG: cache_invalidate in Magento 2 are not errors, there are only debug messages to tell that the cache is invalidated (which is not a problem nor an error). Regarding the system file So the messages like this Broken reference: the 'block1' tries to reorder itself towards 'block2' is not a real ...


Only top voted, non community-wiki answers of a minimum length are eligible