Needs review
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Line item
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
1 Oct 2015 at 14:51 UTC
Updated:
16 Apr 2016 at 11:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
skek commentedComment #3
skek commentedComment #4
skek commentedComment #5
rszrama commentedComment #6
skek commentedAdding additional try catch block for the commerce_line_item_save() function calls.
Comment #7
skek commentedNot passing the quantity field name when we have exception, just leave the field name empty in order to prevent form submission when we have errors.
Comment #8
rszrama commentedHey skek, I don't suppose you can offer up a scenario that would generate the error? Is there some module that's causing problems here that surfaced the issue for you?
Comment #9
skek commented@rszrama,
The issue with try/catch is actually more general and it is connected with entity system.
For example imagine you are getting an PDO exception or an exception from a module that hook on entity operations.
When we do commerce_line_item_save() call, this means that this function can return exception in any reason and we should handle this exception in the place we are calling the function.
If you see for example the CommerceLineItemEntityController::save() method, you will see that the exception is thrown after the rollback.
This means that we will get fatal error screen if for any reason we get an exception, no matter of the source of that exception.
This patch is actually more like UX patch, avoiding WSOD or ugly messages.
The catch() cause in this patch is something that can be modified for example we can set a message notifying customer about an exception has been thrown but I think we should have such try/catch block in order to have better UX.
Also in my understanding, if I call a function, that can throw an exception I always handle the exception and notifying the user that something goes wrong.
I have posted similar issues like this one so it is the same explanation for them.
Regards,
Nikolay