Showing results for 
Search instead for 
Did you mean: 

Get concrete error message of CouldNotSaveException

Get concrete error message of CouldNotSaveException

We need to get concrete error message when Magento\Catalog\Model\ProductRepository throws CouldNotSaveException during saveProduct()

private function saveProduct($product): void
    try {
    } catch (ConnectionException $exception) {
    } catch (\Exception $e) {
        throw new CouldNotSaveException(
            __('The product was unable to be saved. Please try again.'),

An easy way would be just adding the message in that code

__('The product was unable to be saved. Please try again.' . $e->getMessage())

But we can't edit that file, as this is a project hosted in Adobe Cloud. So, how can we get that message instead of application default message?


Re: Get concrete error message of CouldNotSaveException

Hello @iamzain16g69d6 


Regarding edit error message, we can use translation via csv.
Please follow below steps:


To add translation csv file in magento2, you just need to add a folder named:

“i18n” inside your module’s folder, i.e.


Add message string in csv and translation as well.
"String","translation of that strring"


It may help you!
Thank you

Problem solved? Click Accept as Solution!

Re: Get concrete error message of CouldNotSaveException

Hello @iamzain16g69d6 ,


Adobe commerce cloud infra has pretty well architecture so it is from some of your code/database, not from any directory permission or service.

the best approach is to get the project on your local system, same database dump and then change in your local machine vendor folder whatever you want for debugging. (it will be easy to debug and neither the code will be pushed to your commerce cloud project and also it will be good for long term debugging and fixing issues).

below commands will help to get project on your local system :


and if you don't wish to setup on local machine then the bad approach is to override that class and rewrite that function in a custom module but it is not recommended to change or override core functions to debug.


before you follow above approaches, check below files inside var/log folder: 



and other related files.


Hope it helps !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy