public function returnError($errorKeyOrDefinition, $replacementArray = array()) {
    if (is_string($errorKeyOrDefinition)) {
      $errorKey = $errorKeyOrDefinition;
    }
    else {
      $errorKeys = array_keys($errorKeyOrDefinition);
      $errorKey = $errorKeys[0];
    }

    $errorResponse = $this->errorResponseDictionary->getErrorResponse($errorKey);
    if (empty($errorResponse)) {
      $errorResponse = ErrorResponse::FromArray($errorKeyOrDefinition[$errorKey]);
    }

    $appCode = $errorResponse->getCode();
    echo json_encode(array(
      'error' => empty($appCode) ? array('message' => $errorResponse->getFormattedMessage($replacementArray)) :
          array('code' => $appCode, 'message' => $errorResponse->getFormattedMessage($replacementArray))
    ));
    $this->getResponse()->status($errorResponse->getHttpcode());
    throw new Stop($errorResponse->getFormattedMessage($replacementArray));
  }
public function returnError($errorKeyOrDefinition, $replacementArray = array()) {
    if (is_string($errorKeyOrDefinition)) {
      $errorKey = $errorKeyOrDefinition;
    }
    else {
      $errorKeys = array_keys($errorKeyOrDefinition);
      $errorKey = $errorKeys[0];
    }

    $errorResponse = $this->errorResponseDictionary->getErrorResponse($errorKey);
    if (empty($errorResponse)) {
      $errorResponse = ErrorResponse::FromArray($errorKeyOrDefinition[$errorKey]);
    }

    $appCode = $errorResponse->getCode();
    echo json_encode(array(
      'error' => empty($appCode) ? array('message' => $errorResponse->getFormattedMessage($replacementArray)) :
          array('code' => $appCode, 'message' => $errorResponse->getFormattedMessage($replacementArray))
    ));
    $this->getResponse()->status($errorResponse->getHttpcode());
    throw new Stop($errorResponse->getFormattedMessage($replacementArray));
  }
public function returnError ( $ errorKeyOrDefinition , $ replacementArray = array ( ) ) { if ( is_string ( $ errorKeyOrDefinition ) ) { $ errorKey = $ errorKeyOrDefinition ; } else { $ errorKeys = array_keys ( $ errorKeyOrDefinition ) ; $ errorKey = $ errorKeys [ 0 ] ; } $ errorResponse = $ this -> errorResponseDictionary -> getErrorResponse ( $ errorKey ) ; if ( empty ( $ errorResponse ) ) { $ errorResponse = ErrorResponse :: FromArray ( $ errorKeyOrDefinition [ $ errorKey ] ) ; } $ appCode = $ errorResponse -> getCode ( ) ; echo json_encode ( array ( 'error' => empty ( $ appCode ) ? array ( 'message' => $ errorResponse -> getFormattedMessage ( $ replacementArray ) ) : array ( 'code' => $ appCode , 'message' => $ errorResponse -> getFormattedMessage ( $ replacementArray ) ) ) ) ; $ this -> getResponse ( ) -> status ( $ errorResponse -> getHttpcode ( ) ) ; throw new Stop ( $ errorResponse -> getFormattedMessage ( $ replacementArray ) ) ; }
Returns a JSON array displaying the error to the client and stops execution

Example Error Message Definition:
array('ERRORDEF_NO_ACCESS' => array('message' => 'No Access', 'code' => 1007, 'httpcode' => 402));

@param $errorKeyOrDefinition string|array
@param $replacementArray array

@throws \Slim\Exception\Stop
Returns a JSON array displaying the error to the client and stops execution