Exception

jerome·2021년 9월 13일
1

Exception Class


<?php

class Exception
{
    protected $message = 'Unknown exception';   // 예외 메시지
    private   $string;                          // __toString 캐시
    protected $code = 0;                        // 사용자 정의 예외 코드
    protected $file;                            // 예외가 발생한 소스 파일 이름
    protected $line;                            // 예외가 발생한 소스 라인
    private   $trace;                           // backtrace
    private   $previous;                        // 중첩 예외의 경우 이전 예외

    public function __construct($message = null, $code = 0, Exception $previous = null);

    final private function __clone();           // 예외의 복제를 금지합니다.

    final public  function getMessage();        // 예외 메시지
    final public  function getCode();           // 예외 코드
    final public  function getFile();           // 소스 파일 이름
    final public  function getLine();           // 소스 라인
    final public  function getTrace();          // backtrace() 배열
    final public  function getPrevious();       // 이전 예외
    final public  function getTraceAsString();  // trace의 형식화 문자열

    // Overrideable
    public function __toString();               // 출력을 위한 형식화 문자열
}
?>

Method

  • getCode(): 생성자에 전달된 에러 코드를 반환한다.
  • getMessage()
  • getFile()
  • getLine()
  • getTrace()
  • getTraceAsString()
  • getPrevious
  • _toString(): Exception 객체의 정보를 문자열로 반환한다.

고도몰에서 사용하는 Exception

  • 페이지의 전반적인 오류에 따른 처리를 할 수 있도록 지원합니다.
  • Exception은 사용자가 정의해서 사용할 수 있으며 system/src/Framework/Debug/Exception 내에 정의되어 있는 것을 사용할 수 있습니다.
  • 정의되어 있지 않는 경우 시스템 Exception의 기본 예외처리를 사용합니다.
  • 참고:http://doc.godomall5.godomall.com/Learning_More/Exception

AlertBackException

  • 경고창에 메시지 출력 후 페이지 뒤로 가기를 실행한다.
throw new AlertBackException('메시지');

AlertCloseException

  • 경고창에 메시지 출력 후 브라우저를 닫는다.

LayerException

  • 레이어를 띄우고 현재창을 새로고침한다.
use Framework\Debug\Exception\LayerException;

throw new LayerException('메시지', null, null, $formId, $timer, $onUnBlock, $addScript, $isPrint);
throw new LayerException(__('상품 승인 요청이 철회 되었습니다.'));

LayerNotReloadException

  • 레이어를 띄우지만 새로고침하지 않는다.
use Framework\Debug\Exception\LayerNotReloadException;

throw new LayerNotReloadException(__('타임딜 / 원어데이 상품은 수정할 수 없습니다.'));

AlertBackException

  • 경고창에 메시지 출력 후 페이지 뒤로 가기를 실행한다.
use Framework\Debug\Exception\AlertBackException;

try {
} catch (\Exception $e) {
	throw new AlertBackException($e->getMessage());
}

참고

http://php.adamharvey.name/manual/kr/language.exceptions.extending.php

https://m.blog.naver.com/PostView.naver?blogId=hongyou022&logNo=221627176184&targetKeyword=&targetRecommendationCode=1

http://jun.hansung.ac.kr/SWP/PHP/PHP%20Exception%20Handling.html

http://php.adamharvey.name/manual/kr/language.exceptions.extending.php

profile
프론트엔드 개발 🌱

0개의 댓글