initiate a fail result

@param string $code
@param string $message
@param array $errors
@param array $extras
@return Result $Result
487724
public static function fail($code = '', $message = '', $errors = [], $extras = [])
    {
        return self::loadResult(self::FAIL, $code, $message, $errors, $extras);
    }
1047814
protected function addError($code, $extraDetails = null)
    {
        // modified from parent function to support changing the error class
        $errorClass = $this->getSchemaValidationErrorClass();
        $this->errors[] = new $errorClass($code, $extraDetails);
    }
448740
protected function respondWithError(
        $message = 'Bad Request',
        $code = SymfonyResponse::HTTP_BAD_REQUEST,
        array $headers = []
    ) {
        return abort($code, $message, $headers);
    }
4788
protected function fail($message = null, $validation = null)
    {
        $this->trigger('json-fail', $this, $message, $validation);
        $this->trigger('response-fail', $this, $message, $validation);

        $json = array('error' => true);

        if($message) {
            $json['message'] = $message;
        }

        if($validation) {
            $json['validation'] = $validation;
        }

        $body = json_encode($json, JSON_PRETTY_PRINT);

        $this->response
            ->set('headers', 'Content-Type', 'text/json')
            ->set('body', $body);

        return $body;
    }
151730
public static function withErrorCode($errorCode, $message, $innerException= null)
	{
		$ex = new XPath2Exception( $message, $innerException );
		$ex->ErrorCode = $errorCode;
		return $ex;
	}
505131
public static Result failure(int code, String message, List<Error> errors) {
        return new Result(code, message, errors);
    }
441155
public function error($message, $code = 1)
    {
        $this->logger->error($message);

        $this->write($message, self::FC_RED);
        $this->write(PHP_EOL);

        return $code;
    }
139013
public function prepareResult($success, $message, $code, $data, $errors) {
        $this->success = $success;
        $this->code = $code;
        $this->message = $message;
        if(is_null($this->data)) {
            $this->data = array();
        } else {
            if(!is_array($this->data)) {
                $old = $this->data;
                $this->data = array();
                array_push($this->data, $old);
            }
        }
        if(!is_null($data)) {
            if(is_array($data)) {
                $this->data = array_merge($this->data, $data);
            } else {
                array_push($this->data, $data);
            }
        }
        if(is_object($this->errors)) {
            $this->errors = Objects::attrToArray($this->errors);
        }
        if(is_string($this->errors) || is_numeric($this->errors)) {
            $err = $this->errors;
            $this->errors = array();
            $this->errors[0] = $err;
        }
        $this->errors = !is_null($errors) ? array_merge($this->errors, $errors) : $this->errors;
    }
1338904
final protected static function getNewExceptionInstance($message, $code, array $arguments = [])
    {
        $exceptionClassName = get_called_class();

        return new $exceptionClassName(
            vsprintf($message, $arguments),
            $code
        );
    }
578371
public function respondInternalError($code = ApiResponse::CODE_API_ERROR, $message = null): JsonResponse
    {
        return $this->setStatusCode(IlluminateResponse::HTTP_INTERNAL_SERVER_ERROR)
            ->respondWithError($code, $message);
    }
31678
public static <E> Response<E> failure(String message, String code) {
        return new Response<>(false, message, code);
    }
245978
public function respondWithFailure($code = null, array $data = [], $message = null): JsonResponse
    {
        return $this->setStatusCode(IlluminateResponse::HTTP_BAD_REQUEST)->respond([
            'status' => [
                'type' => 'error',
                'message' => $this->getDefaultMessage($code, $message),
                'code' => $code,
                'http_code' => $this->getStatusCode(),
            ],
            'data' => $data,
        ]);
    }
163262
public function respondValidationError(
        $code = ApiResponse::CODE_VALIDATION_ERROR,
        array $errors = [],
        $message = null
    ): JsonResponse {
        return $this->setStatusCode(IlluminateResponse::HTTP_UNPROCESSABLE_ENTITY)
            ->respond([
                'status' => [
                    'type' => 'error',
                    'message' => $this->getDefaultMessage($code, $message),
                    'code' => $code,
                    'http_code' => $this->getStatusCode(),
                ],
                'errors' => $errors,
            ]);
    }
155459
public function internalError($msg = '', $errorCode = null, $headers = [])
    {
        return $this->getErrorResponse($msg, $errorCode, self::HTTP_INTERNAL_SERVER_ERROR, $headers);
    }
354706
public function abort(int $code, string $message = '', array $headers = [])
    {
        if ($code == 404) {
            throw new \Cygnite\Exception\Http\HttpNotFoundException($message);
        }

        throw new \Cygnite\Exception\Http\HttpException($code, $message, null, $headers);
    }
802194
public function raise_error($code, $message)
    {
        global $__page_content, $ERROR_CODE, $ERROR_MESSAGE;

        $ERROR_CODE    = $code;
        $ERROR_MESSAGE = $message;

        include RCUBE_INSTALL_PATH . 'program/steps/utils/error.inc';
        exit;
    }
515516
protected function _throwValidationException(
        $message = null,
        $code = null,
        RootException $previous = null,
        $validator = null
    ) {
        if ($validator === true) {
            $validator = $this;
        }

        throw $this->_createValidationException($message, $code, $previous, $validator);
    }