/** * Creates ApiException from any other exception. * * @param \Exception $e The original exception. * @param null $overrideCode The code to override. * * @return static */ public static function makeFromException($e, $overrideCode = null) { $code = $overrideCode === null ? $e->getCode() : $overrideCode; if ($e instanceof static) { $e->code = $code; return $e; } return new static($e->getMessage(), $code, $e); }
/** * @covers ::spf */ public function test_spf() { // When $e = Exception::spf('Something %s created %d errors.', 'awful', 666); // Then $this->assertSame('Something awful created 666 errors.', $e->getMessage()); }