-
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.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace App\Exceptions; | ||
|
||
use Throwable; | ||
|
||
/** | ||
* Class ServerErrorException | ||
* @package App\Exceptions | ||
*/ | ||
class ServerErrorException extends MyAppException | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected $context; | ||
|
||
/** | ||
* ServerErrorException constructor. | ||
* @param array $context | ||
* @param string $message | ||
* @param int $code | ||
* @param Throwable|null $previous | ||
*/ | ||
public function __construct(array $context = [], string $message = '', int $code = 0, ?Throwable $previous = null) | ||
{ | ||
parent::__construct($message, $code, $previous); | ||
$this->context = $context; | ||
} | ||
|
||
/** | ||
* @return array ログ出力時の追加情報 | ||
*/ | ||
public function getContext(): array | ||
{ | ||
return $this->context; | ||
} | ||
|
||
/** | ||
* @return int HTTP ステータスコード | ||
*/ | ||
public function getStatusCode(): int | ||
{ | ||
return 500; | ||
} | ||
|
||
/** | ||
* @return string ユーザ向けのメッセージ | ||
*/ | ||
public function getUserMessage(): string | ||
{ | ||
return 'サーバエラーが発生しました。もう一度同じ操作をお試しください。問題が解消しない場合は、お問い合わせ窓口よりご報告をお願いいたします。'; | ||
} | ||
} |