Skip to content

Commit bb5baf8

Browse files
committed
Add wrap() method to WebRequestException
1 parent 0acd057 commit bb5baf8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Exceptions/WebRequestException.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace WhoopsStackdriver\Exceptions;
44

55
use Exception;
6+
use Throwable;
67

78
class WebRequestException extends Exception implements ExceptionWithContext
89
{
@@ -73,4 +74,13 @@ public function setContext(array $context) : self
7374
$this->context = $context;
7475
return $this;
7576
}
77+
78+
/**
79+
* @param Throwable $throwable
80+
* @return static
81+
*/
82+
public static function wrap(Throwable $throwable) : self
83+
{
84+
return new static($throwable->getMessage(), $throwable->getCode(), $throwable);
85+
}
7686
}

0 commit comments

Comments
 (0)