RarException::setUsingExceptions
(PECL rar >= 2.0.0)
RarException::setUsingExceptions — 예외가 있는 오류 처리 활성화 및 비활성화
설명
public static RarException::setUsingExceptions(bool $using_exceptions
): void
인수가 true
인 경우에만 UnRAR 라이브러리에 오류가 발생했을 때 경고를 표시하고 오류를 나타내는 특수 값을 반환하는 대신 RarException 유형의 예외가 발생합니다.
라이브러리 외부에서 발생하는 다음 오류에 대해서도 예외가 발생합니다(해당 오류 코드는 -1).
- 닫힌 RarArchive 개체 또는 첫 번째 개체와 관련된 RarEntry 개체에 대해 일부 작업을 시도합니다.
- RarArchive::getEntry()로 존재하지 않는 항목을 가져오려고 합니다.
매개변수
using_exceptions
- 예외 발생을 활성화하려면
true
, 비활성화하려면false
(기본값)여야 합니다.
반환 값
값이 반환되지 않습니다.
Examples
예제 #1 RarException::setUsingExceptions() 예제
<?php
var_dump(RarException::isUsingExceptions());
$arch = RarArchive::open("does_not_exist.rar");
var_dump($arch);
RarException::setUsingExceptions(true);
var_dump(RarException::isUsingExceptions());
$arch = RarArchive::open("does_not_exist.rar");
var_dump($arch); //not reached
?>
위의 예는 다음과 유사한 결과를 출력합니다.
bool(false) Warning: RarArchive::open(): Failed to open does_not_exist.rar: ERAR_EOPEN (file open error) in C:\php_rar\trunk\tests\test.php on line 3 bool(false) bool(true) Fatal error: Uncaught exception 'RarException' with message 'unRAR internal error: Failed to open does_not_exist.rar: ERAR_EOPEN (file open error)' in C:\php_rar\trunk\tests\test.php:8 Stack trace: #0 C:\php_rar\trunk\tests\test.php(8): RarArchive::open('does_not_exist....') #1 {main} thrown in C:\php_rar\trunk\tests\test.php on line 8
기타
- RarException::isUsingExceptions() - 예외가 있는 오류 처리가 사용 중인지 확인