This repository has been archived by the owner on Feb 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from articstudio/develop
v1.0.2
- Loading branch information
Showing
42 changed files
with
397 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Articstudio\Bitbucket\Contract; | ||
|
||
use Psr\Container\ContainerInterface as ContainerContract; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
interface FoundHandler { | ||
|
||
public function __construct(ContainerContract $container); | ||
|
||
public function handle(ServerRequestInterface $request, ResponseInterface $response); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Articstudio\Bitbucket\Contract; | ||
|
||
use Psr\Container\ContainerInterface as ContainerContract; | ||
use Throwable; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
interface ThrowableHandler { | ||
|
||
public function __construct(ContainerContract $container); | ||
|
||
public function handle(Throwable $throwable, ServerRequestInterface $request, ResponseInterface $response); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Articstudio\Bitbucket\Exception\Deploy; | ||
|
||
use RuntimeException; | ||
|
||
class RuntimeException extends RuntimeException { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Articstudio\Bitbucket\Exception\Middleware; | ||
|
||
use InvalidArgumentException; | ||
|
||
class InvalidHeaderException extends InvalidArgumentException { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Articstudio\Bitbucket\Exception\Middleware; | ||
|
||
use InvalidArgumentException; | ||
|
||
class InvalidPayloadException extends InvalidArgumentException { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Articstudio\Bitbucket\Exception\Middleware; | ||
|
||
use InvalidArgumentException; | ||
|
||
class InvalidRepositoryException extends InvalidArgumentException { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Articstudio\Bitbucket\Exception\Middleware; | ||
|
||
use InvalidArgumentException; | ||
|
||
class WrongPayloadException extends InvalidArgumentException { | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Articstudio\Bitbucket\Exception; | ||
|
||
use Throwable; | ||
|
||
trait TrowByTrait { | ||
|
||
protected final function thrownByParent(Throwable $exception, $concrete = null, $method = null) { | ||
return $this->thrownBy($exception, parent::class, $concrete, $method); | ||
} | ||
|
||
protected final function thrownBy(Throwable $exception, $by, $concrete = null, $method = null) { | ||
$trace = $exception->getTrace()[0]; | ||
if ($concrete && !($exception instanceof $concrete)) { | ||
return false; | ||
} | ||
if ($method && $trace['function'] !== $method) { | ||
return false; | ||
} | ||
return $trace['class'] === $by; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Articstudio\Bitbucket\Handler; | ||
|
||
use Articstudio\Bitbucket\ContainerAwareTrait; | ||
use Psr\Container\ContainerInterface as ContainerContract; | ||
|
||
class AbstractHandler { | ||
|
||
use ContainerAwareTrait; | ||
|
||
public function __construct(ContainerContract $container) { | ||
$this->setContainer($container); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Articstudio\Bitbucket\Handler; | ||
|
||
use Articstudio\Bitbucket\Handler\AbstractHandler; | ||
use Articstudio\Bitbucket\Contract\ThrowableHandler as ThrowableHandlerContract; | ||
use Throwable; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class ErrorHandler extends AbstractHandler implements ThrowableHandlerContract { | ||
|
||
public function handle(Throwable $throwable, ServerRequestInterface $request, ResponseInterface $response) { | ||
$this->container->logger->error($throwable->getMessage(), $throwable->getTrace()); | ||
$response->getBody()->write('<h2>Error</h2>'); | ||
$response->getBody()->write('<h4>' . $throwable->getMessage() . '</h4><pre>' . $throwable->getTraceAsString() . '</pre>'); | ||
return $response->withStatus(500, $throwable->getMessage()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Articstudio\Bitbucket\Handler; | ||
|
||
use Articstudio\Bitbucket\Handler\AbstractHandler; | ||
use Articstudio\Bitbucket\Contract\ThrowableHandler as ThrowableHandlerContract; | ||
use Throwable; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class ExceptionHandler extends AbstractHandler implements ThrowableHandlerContract { | ||
|
||
public function handle(Throwable $throwable, ServerRequestInterface $request, ResponseInterface $response) { | ||
$this->container->logger->warning($throwable->getMessage(), $throwable->getTrace()); | ||
$response->getBody()->write('<h2>Exception</h2>'); | ||
$response->getBody()->write('<h4>' . $throwable->getMessage() . '</h4><pre>' . $throwable->getTraceAsString() . '</pre>'); | ||
$response->getBody()->write('<h4>Headers</h4><pre>' . print_r($this->container->headersInfo->all(), true) . '</pre>'); | ||
$response->getBody()->write('<h4>Payload</h4><pre>' . print_r($this->container->payload, true) . '</pre>'); | ||
return $response->withStatus(500, $throwable->getMessage()); | ||
} | ||
|
||
} |
Oops, something went wrong.