Get error message from the response array.

@param array $result

@return null|string
179781
private function getErrorMessage(array $result)
    {
        $errorMessage = '';
        if (isset($result['errors'][0]['property']) && isset($result['errors'][0]['message'])) {
            $errorMessage = $result['errors'][0]['property'] . ': ' . $result['errors'][0]['message'];
        }
        return $errorMessage;
    }
767230
private function _decode($result, $field = null)
    {
        $this->data = json_decode($result, true);
        if (!empty($this->data['errcode'])) {
            $this->errCode = $this->data['errcode'];
            $this->errMsg = $this->data['errmsg'];
            return false;
        }
        if ($this->data && !is_null($field)) {
            if (isset($this->data[$field])) {
                return $this->data[$field];
            } else {
                return false;
            }
        }
        return $this->data;
    }
1020796
private function extractError($response)
    {
        $error = array();
        $response = json_decode($response);
        if (property_exists($response, 'error')) {
            if (is_string($response->error->message)) {
                $message = $response->error->message;
            } elseif (is_object($response->error->message)) {
                $message = $response->error->message->value;
            } else {
                $message = "Unknown error";
            }
            $error['Message'] = $message;
            return $error;
        }
        return null;
    }
573744
protected function fail(Result $result, $name, $value = null, array $context = array())
    {
        if (!isset($context[':name'])) {
            $context[':name'] = $this->sensible($name);
        }

        if (is_scalar($value) && !isset($context[':value'])) {
            $context[':value'] = (string) $value;
        }

        $message = str_replace(array_keys($context), array_values($context), $this->message);
        $result->addError($name, $message);

        return false;
    }
1089388
protected function prepareAccessTokenResponse(array $result)
    {
        $jwt = (new Parser())->parse($result['access_token']);
        $result['resource_owner_id'] = $jwt->getClaim('sub');
        $result['role'] = $jwt->getClaim('role');

        return $result;
    }
739307
protected function _checkResult($result) {
        $rvalue = true;
        foreach ($result as $socketName => $value) {
            if ($value !== true) {
                Mage::helper('turpentine/debug')->logWarn(
                    'Error in Varnish action result for server [%s]: %s',
                    $socketName, $value );
                $rvalue = false;
            }
        }
        return $rvalue;
    }
959135
private function getExceptionFromResult(Pjb62\Exception\JavaException $result): Exception\JavaExceptionInterface
    {
        $found = false;
        $exceptionClass = '';

        $message = $result->__get('message')->__toString();

        foreach ($this->msgPatternsMapping as $exceptionClass => $pattern) {
            if (preg_match($pattern, $message)) {
                $found = true;
                break;
            }
        }

        if (!$found) {
            $exceptionClass = $this->defaultException;
        }

        $cls = '\\Soluble\\Japha\\Bridge\\Exception\\'.$exceptionClass;

        // Public message, mask any login/passwords
        $message = preg_replace('/user=([^&\ ]+)|password=([^&\ ]+)/', '****', $message);
        $stackTrace = $result->getCause()->__toString();
        $code = $result->getCode();

        $driverException = null;
        if ($result instanceof \Exception) {
            $driverException = $result;
        }

        // Getting original class name from cause
        preg_match('/Cause: ([^:]+):/', $message, $matches);
        if (count($matches) > 1) {
            $javaExceptionClass = $matches[1];
        } else {
            $javaExceptionClass = 'unkwown';
        }

        // Getting cause from message
        $tmp = explode('Cause: ', $message);
        if (count($tmp) > 1) {
            array_shift($tmp);
            $cause = trim(implode(', ', $tmp));
        } else {
            $cause = $message;
        }
        $e = new $cls(
            $message,
            $cause,
            $stackTrace,
            $javaExceptionClass,
            $code,
            $driverException,
            null
        );

        $this->logException($e, $exceptionClass);

        return $e;
    }
1290745
protected function getAjaxErrorResponse(ValidationResult $result)
    {
        // Ajax form submissions accept json encoded errors by default
        $acceptType = $this->getRequest()->getHeader('Accept');
        if (strpos($acceptType, 'application/json') !== false) {
            // Send validation errors back as JSON with a flag at the start
            $response = new HTTPResponse(json_encode($result->getMessages()));
            $response->addHeader('Content-Type', 'application/json');
            return $response;
        }

        // Send the newly rendered form tag as HTML
        $this->form->loadMessagesFrom($result);
        $response = new HTTPResponse($this->form->forTemplate());
        $response->addHeader('Content-Type', 'text/html');
        return $response;
    }
1184342
public function renderErrors($errors)
    {
        if (empty($errors)) {
            return null;
        }

        $message = '';

        foreach ($errors as &$error) {
            foreach ($error as $errorCode => &$errorMsg) {
                $message .= $this->errorMapper($errorCode, $errorMsg);
            }
        }

        return $message;
    }
879295
protected function getErrorMessage(array $errors)
    {
        $error_message = '';
        foreach ($errors as $error) {
            $error_message .= $this->parseError($error) . PHP_EOL . PHP_EOL;
        }

        return $error_message;
    }
151276
protected function formatFailure($result)
    {
        $appConfig = $this->di->get('config')['application'];
        $inflector = $this->di->get('inflector');

        $result->errors = [];

        //for each errorStore, build one or more error objects
        foreach ($this->errors as $error) {

            //if this error includes a list of validation issues, map them into error objects and concat the result
            if ($error->validationList) {
                $validationErrors = array_map(function (Message $validation) use ($error, $appConfig, $inflector) {
                    $field = $inflector->normalize($validation->getField(), $appConfig['propertyFormatTo']);
                    $details = [
                        'code' => $error->code,
                        'title' => $error->title,
                        'detail' => $validation->getMessage(),
                        'source' => ['pointer' => "/data/attributes/$field"],
                        'meta' => ['field' => $field]
                    ];
                    if ($appConfig['debugApp'] && $error->dev) {
                        $details['meta']['developer_message'] = $error->dev;
                    }
                    return $details;
                }, $error->validationList);

                $result->errors = array_merge($result->errors, $validationErrors);

                //however, if it's a plain error, concat an error object with some additional trace information
            } else {
                $details = [
                    'title' => $error->title,
                    'code' => $error->code,
                    'detail' => $error->more,
                ];

                //it doesn't make much sense to add stacktrace info to validation errors, right?
                if ($appConfig['debugApp']) {
                    $meta = array_filter([ //clears up empty keys
                        'developer_message' => $error->dev,
                        'file' => $error->file,
                        'line' => $error->line,
                        'stack' => $error->stack,
                        'context' => $error->context,
                    ]);

                    if ($meta) {
                        $details['meta'] = $meta;
                    }
                }

                $result->errors[] = $details;
            }
        }
    }
955304
protected function handleResultError($result, $logger)
	{
		$decodeResult = json_decode($result, true);
		if (isset($decodeResult['message']) && isset($decodeResult['errorCode'])) {
			$logger->error($decodeResult['errorCode'] . ': ' . $decodeResult['message']);
			throw new \Adyen\AdyenException($decodeResult['message'], $decodeResult['errorCode'], null,
				$decodeResult['status'], $decodeResult['errorType']);
		}
		$logger->error($result);
		throw new \Adyen\AdyenException($result);
	}
653126
protected function pushResult()
    {
        if ($this->result !== null) {
            array_push($this->resultStack, $this->result);
        }
        $this->result = new ErrorResult();
        return $this->result;
    }
589573
function getResult (err) {
        var res = {
            valid: true,
            errors: []
        };

        if (err !== null) {
            res.valid = false;
            res.errors.push(err);
        }

        return res;
    }
1184802
protected function getError($response_data, $status) {
    if (!empty($response_data->error)) {
      $error = $response_data->error;
      $message = sprintf('%s %s: %s',
        $error->statuscode,
        $error->statusdesc,
        $error->errormessage);
    }
    else {
      $message = sprintf('Error code: %s. No reason was given by Pingdom for the error.', $status);
    }
    return $message;
  }
862424
public static function buildMessage(ResultException $result)
    {
        $translateKey = self::TRANSLATE_KEY_PREFIX . $result->globalCode;
        $message = self::translate($translateKey);

        return empty($message) ? $result->getAlias() : $message;
    }
988994
protected function fetchResponseError($response)
	{
		if (isset($response['errors'])) {
			$first = reset($response['errors']);
			return [
				'code' => $first['code'],
				'message' => $first['message'],
			];
		}
		return null;
	}