PHP 예외 참조
PHP 예외 객체
예외는 함수 및 메서드에서 오류 및 예기치 않은 동작에 대한 정보를 보내는 데 사용됩니다.
Exception 개체에는 공용 속성이 없지만 생성자와 메서드를 사용하여 쓰거나 읽을 수 있는 private 및 protected 속성이 있습니다.
Exception 개체에는 다음과 같은 메서드가 있습니다.
Method | Description |
---|---|
Exception() | The contructor of the Exception object |
getCode() | Returns the exception code |
getFile() | Returns the full path of the file in which the exception was thrown |
getMessage() | Returns a string describing why the exception was thrown |
getLine() | Returns the line number of the line of code which threw the exception |
getPrevious() | If this exception was triggered by another one, this method returns the previous exception. If not, then it returns null |
getTrace() | Returns an array with information about all of the functions that were running at the time the exception was thrown |
getTraceAsString() | Returns the same information as getTrace(), but in a string |