0

Is their any way we can skip through this ?

throw new \Magento\Framework\Exception\LocalizedException(
                                __('Any error Msg.'),
                                $e
                            );

I have created an application where i refund shipping amount online when i upload a csv with order numbers. but for some order it did not pass through as i get exception & the execution stops.

I need to skip if error thrown & start execution of another row in csv.

2
  • any thoughts how to fix it ?
    – devhs
    May 28, 2021 at 11:36
  • Please provide some code, in what line exactly you have your problem, then I should be able to point you in right direction :)
    – dudzio
    May 28, 2021 at 13:47

1 Answer 1

0

Sure, just catch the exception where you want to continue execution...

try {
    SomeOperation();
} catch (SomeException $e) {
    // do nothing... php will ignore and continue    
}

Or you can add error message in log

try {
    /* Some logic that could throw an Exception */
} catch (\Exception $e) {
    $this->logger->critical($e->getMessage());
}

It will continue your execution.

5
  • The code fails here - catch (\Magento\Framework\Exception\LocalizedException $e) { if (!$captureTxn) { throw new \Magento\Framework\Exception\LocalizedException( __('If the invoice was created offline, try creating an offline credit memo.'), $e ); } throw $e; } Magento2/vendor/magento/module-sales/Model/Order/Payment.php
    – devhs
    May 28, 2021 at 11:56
  • After this exception the rest of the execution does not ru
    – devhs
    May 28, 2021 at 11:57
  • Yes , that's why i have said that not to write anything in catch
    – ZealousWeb
    May 28, 2021 at 12:10
  • try { /* Some logic that could throw an Exception */ } catch (\Exception $e) { $this->logger->critical($e->getMessage()); }
    – ZealousWeb
    May 28, 2021 at 12:13
  • no i can not update like this
    – devhs
    May 28, 2021 at 13:23

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.