/**
  * Method to find errors in the given data.
  * @param  array   $data           The data to search for errors.
  * @param  boolean $warningIsError Whether warnings needs to be treated as errors.
  */
 public static function evaluateErrors($data, $warningIsError = true)
 {
     $apiException = new ApiException(ApiResponse::HTTP_RESPONSE_CODE_BAD_REQUEST);
     foreach ($data as $key => $value) {
         if (substr($key, 0, 6) == 'error_' && !empty($value) && !($warningIsError === false && $key == 'error_warning')) {
             // Check if it's an array, this is possible in the case of custom field errors.
             if (is_array($value) && !empty($value)) {
                 foreach ($value as $message) {
                     $apiException->addError($key, $message);
                 }
             } else {
                 $apiException->addError($key, $value);
             }
         }
         // json responses (ie add product to cart) contain error keys so check for them too
         if ($key == 'error') {
             ApiException::findErrors($value, 'error', $apiException, $warningIsError);
         }
     }
     if ($apiException->containsErrors()) {
         throw $apiException;
     }
 }