<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.rarexception.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'rarexception.setusingexceptions.php',
    1 => 'RarException::setUsingExceptions',
    2 => 'Active ou d&eacute;sactive les exceptions dans le gestionnaire d\'erreurs',
  ),
  'up' => 
  array (
    0 => 'class.rarexception.php',
    1 => 'RarException',
  ),
  'prev' => 
  array (
    0 => 'rarexception.isusingexceptions.php',
    1 => 'RarException::isUsingExceptions',
  ),
  'next' => 
  array (
    0 => 'book.zip.php',
    1 => 'Zip',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/rar/rarexception/setusingexceptions.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="rarexception.setusingexceptions" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">RarException::setUsingExceptions</h1>
  <p class="verinfo">(PECL rar &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">RarException::setUsingExceptions</span> &mdash; <span class="dc-title">Active ou désactive les exceptions dans le gestionnaire d&#039;erreurs</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-rarexception.setusingexceptions-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>RarException::setUsingExceptions</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$using_exceptions</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

  <p class="simpara">
   Si et seulement si l&#039;argument vaut <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, alors, au lieu d&#039;émettre des alertes
   et de retourner des valeurs spéciales indiquant une erreur lorsque la
   bibliothèque UnRAR rencontre une erreur, une exception de type
   <span class="type"><a href="class.rarexception.php" class="type RarException">RarException</a></span> est émise.
  </p>
  <p class="simpara">
   Les exceptions seront également lancées pour les erreurs suivantes,
   qui surviennent en dehors de la bibliothèque (leurs codes erreurs seront -1) :
  </p>
  <ul class="itemizedlist">
   <li class="listitem">
    <span class="simpara">
     tentative d&#039;une opération sur un objet <span class="type"><a href="class.rararchive.php" class="type RarArchive">RarArchive</a></span> clos ou
     un objet <span class="type"><a href="class.rarentry.php" class="type RarEntry">RarEntry</a></span> relatif au premier ;
    </span>
   </li>

   <li class="listitem">
    <span class="simpara">
     tentative de récupération d&#039;une entrée qui n&#039;existe pas avec la méthode
     <span class="methodname"><a href="rararchive.getentry.php" class="methodname">RarArchive::getEntry()</a></span>.
    </span>
   </li>
  </ul>

 </div>


 <div class="refsect1 parameters" id="refsect1-rarexception.setusingexceptions-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <dl>
   
    <dt><code class="parameter">using_exceptions</code></dt>
    <dd>
     <span class="simpara">
      Doit valoir <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> pour activer l&#039;émission d&#039;exceptions, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> pour le
      désactiver (par défaut).
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-rarexception.setusingexceptions-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="simpara">
   Aucune valeur n&#039;est retournée.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-rarexception.setusingexceptions-examples">
  <h3 class="title">Exemples</h3>
  <div class="example" id="example-1">
   <p><strong>Exemple #1 Exemple avec <span class="function"><strong>RarException::setUsingExceptions()</strong></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">RarException</span><span style="color: #007700">::</span><span style="color: #0000BB">isUsingExceptions</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">$arch </span><span style="color: #007700">= </span><span style="color: #0000BB">RarArchive</span><span style="color: #007700">::</span><span style="color: #0000BB">open</span><span style="color: #007700">(</span><span style="color: #DD0000">"does_not_exist.rar"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$arch</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">RarException</span><span style="color: #007700">::</span><span style="color: #0000BB">setUsingExceptions</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">RarException</span><span style="color: #007700">::</span><span style="color: #0000BB">isUsingExceptions</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">$arch </span><span style="color: #007700">= </span><span style="color: #0000BB">RarArchive</span><span style="color: #007700">::</span><span style="color: #0000BB">open</span><span style="color: #007700">(</span><span style="color: #DD0000">"does_not_exist.rar"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$arch</span><span style="color: #007700">); </span><span style="color: #FF8000">//non atteint<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>Résultat de l&#039;exemple ci-dessus est similaire à :</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">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 &#039;RarException&#039; with message &#039;unRAR internal error: Failed to open does_not_exist.rar: ERAR_EOPEN (file open error)&#039; in C:\php_rar\trunk\tests\test.php:8
Stack trace:
#0 C:\php_rar\trunk\tests\test.php(8): RarArchive::open(&#039;does_not_exist....&#039;)
#1 {main}
  thrown in C:\php_rar\trunk\tests\test.php on line 8</pre>
</div>
   </div>
  </div>
 </div>



 <div class="refsect1 seealso" id="refsect1-rarexception.setusingexceptions-seealso">
  <h3 class="title">Voir aussi</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="rarexception.isusingexceptions.php" class="methodname" rel="rdfs-seeAlso">RarException::isUsingExceptions()</a> - V&eacute;rifie si le gestionnaire d'erreur utilise les exceptions ou non</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>