protected function setResponseError($error, int $statusCode = 500) : void
    {
        if ($error instanceof \Exception) {
            $error = $error->getMessage();
        }

        $this->response['message'] = (string)$error;
        $this->response['status'] = $statusCode;
    }