| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | namespace Aurora\System\Exceptions; |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | class BaseException extends Exception |
| 18: | { |
| 19: | |
| 20: | |
| 21: | |
| 22: | protected $aObjectParams; |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | protected $oPrevious; |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | public function __construct($iCode, $oPrevious = null, $aParams = array(), $aObjectParams = array()) |
| 36: | { |
| 37: | if (\Aurora\System\Exceptions\ErrorCodes::Validation_FieldIsEmpty === $iCode) { |
| 38: | \Aurora\System\Api::Log('Exception error: ' . \Aurora\System\Exceptions\ErrorCodes::GetMessageByCode($iCode, $aParams), \Aurora\System\Enums\LogLevel::Error); |
| 39: | $iCode = \Aurora\System\Exceptions\ErrorCodes::Validation_FieldIsEmpty_OutInfo; |
| 40: | } |
| 41: | |
| 42: | $this->aObjectParams = $aObjectParams; |
| 43: | $this->oPrevious = $oPrevious ? $oPrevious : null; |
| 44: | |
| 45: | if ($this->oPrevious) { |
| 46: | \Aurora\System\Api::Log('Previous Exception: ' . $this->oPrevious->getMessage(), \Aurora\System\Enums\LogLevel::Error); |
| 47: | } |
| 48: | |
| 49: | parent::__construct(\Aurora\System\Exceptions\ErrorCodes::GetMessageByCode($iCode, $aParams), $iCode); |
| 50: | } |
| 51: | |
| 52: | |
| 53: | |
| 54: | |
| 55: | public function GetObjectParams() |
| 56: | { |
| 57: | return $this->aObjectParams; |
| 58: | } |
| 59: | |
| 60: | |
| 61: | |
| 62: | |
| 63: | public function GetPreviousMessage() |
| 64: | { |
| 65: | $sMessage = ''; |
| 66: | if ($this->oPrevious instanceof \MailSo\Imap\Exceptions\NegativeResponseException) { |
| 67: | $oResponse = $this->oPrevious->GetLastResponse(); |
| 68: | |
| 69: | $sMessage = $oResponse instanceof \MailSo\Imap\Response ? |
| 70: | $oResponse->Tag . ' ' . $oResponse->StatusOrIndex . ' ' . $oResponse->HumanReadable : ''; |
| 71: | } elseif ($this->oPrevious instanceof \MailSo\Smtp\Exceptions\NegativeResponseException) { |
| 72: | $sMessage = $this->oPrevious->getMessage(); |
| 73: | |
| 74: | |
| 75: | |
| 76: | |
| 77: | } elseif ($this->oPrevious instanceof \Exception) { |
| 78: | $sMessage = $this->oPrevious->getMessage(); |
| 79: | } |
| 80: | |
| 81: | return $sMessage; |
| 82: | } |
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: | public function GetPreviousException() |
| 88: | { |
| 89: | return $this->oPrevious; |
| 90: | } |
| 91: | } |
| 92: | |