Skip to content

String based error handling in Mage_Sales_Model_Quote:addProductAdvanced etc. #55

Closed
@amenk

Description

@amenk

The function addProductAdvanced and the underlying functions return strings if an error occurred.

One example from Mage_Catalog_Model_Product_Type_Abstract::_prepareProduct:

    try {
        $options = $this->_prepareOptions($buyRequest, $product, $processMode);
    } catch (Mage_Core_Exception $e) {
        return $e->getMessage();
    }

They should use exceptions instead - so a better handling of the different cases for an error can take place such as

  • distinguishing between the different kinds of errors
  • logging backtraces

As a result, parts like

    if (is_string($cartCandidates)) {
        return $cartCandidates;
    }

can be omitted then because the exceptions are passed automatically.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions