mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 14:28:56 +00:00

Use consistent line terminator. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@317663 c90b9560-bf6c-de11-be94-00142212c4b1
124 lines
3.5 KiB
XML
124 lines
3.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<refentry xml:id="rarexception.setusingexceptions" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>RarException::setUsingExceptions</refname>
|
|
<refpurpose>Activate and deactivate error handling with exceptions</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <modifier>static</modifier> <type>void</type><methodname>RarException::setUsingExceptions</methodname>
|
|
<methodparam><type>bool</type><parameter>using_exceptions</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
If and only if the argument is &true;, then, instead of emitting warnings and returning a special value indicating error when the UnRAR library encounters an error, an exception of type <type>RarException</type> will be thrown.
|
|
</para>
|
|
<para>
|
|
Exceptions will also be thrown for the following errors, which occur outside the library (their error code will be -1):
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
attempting some operations on a closed <type>RarArchive</type> object or a <type>RarEntry</type> object relative to the first;
|
|
</simpara>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<simpara>
|
|
attempting to get an entry that does not exist with <methodname>RarArchive::getEntry</methodname>.
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>using_exceptions</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Should be &true; to activate exception throwing, &false; to deactivate (the default).
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>RarException::setUsingExceptions</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?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
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
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
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><methodname>RarException::isUsingExceptions</methodname></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|