Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
adding ErrorResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Joan Fabrégat committed Feb 27, 2018
1 parent 80fe740 commit c75f5d9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "codeinchq/lib-psr7responses",
"version": "1.0.0",
"version": "1.1.0",
"description": "A collection of PSR-7 responses",
"homepage": "https://github.com/codeinchq/lib-psr7responses",
"type": "library",
"license": "MIT",
"require": {
"php": ">=7.2",
"psr/http-message": "^1.0",
"guzzlehttp/psr7": "^1.4"
"guzzlehttp/psr7": "^1.4",
"codeinchq/lib-errordisplay": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^7"
Expand All @@ -35,4 +36,4 @@
"*": "dist"
}
}
}
}
23 changes: 16 additions & 7 deletions src/ErrorResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,30 @@
//
declare(strict_types = 1);
namespace CodeInc\Psr7Responses;
use GuzzleHttp\Psr7\Response;
use CodeInc\ErrorDisplay\HtmlErrorRenderer;


/**
* Class ErrorResponse
*
* @package CodeInc\Psr7Responses
* @author Joan Fabrégat <[email protected]>
* @todo
*/
class ErrorResponse extends Response {
public function __construct(\Throwable $error, int $status = 200, array $headers = [],
string $version = '1.1', ?string $reason = null)
class ErrorResponse extends HtmlResponse {
/**
* ErrorResponse constructor.
*
* @param \Throwable $throwable
* @param null|string $charset
* @param int $status
* @param array $headers
* @param string $version
* @param null|string $reason
*/
public function __construct(\Throwable $throwable, ?string $charset = null, int $status = 200,
array $headers = [], string $version = '1.1', ?string $reason = null)
{
//todo
//parent::__construct($status, $headers, $body, $version, $reason);
parent::__construct((new HtmlErrorRenderer($throwable))->get(),
$charset, $status, $headers, $version, $reason);
}
}

0 comments on commit c75f5d9

Please sign in to comment.