cvs: peardoc /nl STATUS /nl/core/pear pear.xml /nl/core/pear/pear seterrorhandling.xml /nl/package fileformats.xml

From: Date: Tue, 26 Aug 2003 12:08:44 +0000
Subject: cvs: peardoc /nl STATUS /nl/core/pear pear.xml /nl/core/pear/pear seterrorhandling.xml /nl/package fileformats.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-1411@lists.php.net to get a copy of this message
vincent Tue Aug 26 08:08:44 2003 EDT Modified files: /peardoc/nl STATUS /peardoc/nl/core/pear pear.xml /peardoc/nl/core/pear/pear seterrorhandling.xml /peardoc/nl/package fileformats.xml Log: Change this tobe in sync with en

Index: peardoc/nl/STATUS diff -u peardoc/nl/STATUS:1.8 peardoc/nl/STATUS:1.9 --- peardoc/nl/STATUS:1.8 Sat Aug 23 08:33:59 2003 +++ peardoc/nl/STATUS Tue Aug 26 08:08:41 2003 @@ -1,4 +1,4 @@ -<!-- $Id: STATUS,v 1.8 2003/08/23 12:33:59 vincent Exp $ --> +<!-- $Id: STATUS,v 1.9 2003/08/26 12:08:41 vincent Exp $ --> <translation lang="dutch"> <translators> @@ -12,6 +12,7 @@ ./core/pear/pear: intro.xml +seterrorhandling.xml </filelist> </translation> @@ -66,7 +67,6 @@ pear.xml popexpect.xml registershutdownfunction.xml -seterrorhandling.xml ./package: caching.xml Index: peardoc/nl/core/pear/pear.xml diff -u peardoc/nl/core/pear/pear.xml:1.2 peardoc/nl/core/pear/pear.xml:1.3 --- peardoc/nl/core/pear/pear.xml:1.2 Fri Aug 15 14:05:11 2003 +++ peardoc/nl/core/pear/pear.xml Tue Aug 26 08:08:42 2003 @@ -1,4 +1,4 @@ -<!-- $Id: pear.xml,v 1.2 2003/08/15 18:05:11 vincent Exp $ --> +<!-- $Id: pear.xml,v 1.3 2003/08/26 12:08:42 vincent Exp $ --> <sect1 id="core.pear.pear"> <title>PEAR</title> <titleabbrev>PEAR base en error handling class</titleabbrev> @@ -16,6 +16,7 @@ &core.pear.pear.getstaticproperty; &core.pear.pear.registershutdownfunction; &core.pear.pear.iserror; + &core.pear.pear.raiseerror; &core.pear.pear.seterrorhandling; &core.pear.pear.expecterror; &core.pear.pear.popexpect; Index: peardoc/nl/core/pear/pear/seterrorhandling.xml diff -u peardoc/nl/core/pear/pear/seterrorhandling.xml:1.3 peardoc/nl/core/pear/pear/seterrorhandling.xml:1.4 --- peardoc/nl/core/pear/pear/seterrorhandling.xml:1.3 Sat Aug 23 10:27:57 2003 +++ peardoc/nl/core/pear/pear/seterrorhandling.xml Tue Aug 26 08:08:43 2003 @@ -1,8 +1,7 @@ -<!-- $Id: seterrorhandling.xml,v 1.3 2003/08/23 14:27:57 vincent Exp $ --> <refentry id="core.pear.pear.seterrorhandling"> <refnamediv> <refname>PEAR::setErrorHandling()</refname> - <refpurpose>Stelt de handling van errors gegenereerd door PEAR pakketten in</refpurpose> + <refpurpose>sets handling of errors generated through PEAR packages</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> @@ -23,11 +22,14 @@ <refsect1 id="core.pear.pear.seterrorhandling.desc"> &title.desc; <para> - <function>setErrorHandling</function> kan worden gebruikt als een object, maar ook statisch. - Als statisch opgeroepen, <function>setErrorHandling</function> stelt het standaard gedrag voor alle - PEAR objecten in. Als een object opgeroepen, - <function>setErrorHandling</function> stelt - het standaard gedrag in voor dat object. + <function>setErrorHandling</function> can be invoked as both a standard + object method ($obj->setErrorHandling) and as a static method + (PEAR::setErrorHandling). If called + statically, <function>PEAR::setErrorHandling</function> sets the default + error handling behaviour for all + PEAR objects (global error handling behaviour). If called as an object method, + <function>$obj->setErrorHandling</function> sets + the default error handling for only that object (local error handling behaviour). </para> </refsect1> <refsect1 id="core.pear.pear.seterrorhandling.parameter"> @@ -36,77 +38,183 @@ <itemizedlist> <listitem> <para> - <parameter>integer $mode</parameter> - een van de volgende constanten + <parameter>integer $mode</parameter> - one of the following constants <itemizedlist> <listitem> <para> - <constant>PEAR_ERROR_RETURN</constant> Als er een error is, een - <classname>PEAR_Error</classname> wordt terug gegeven door de functie, - waar de error gebeurde. + <constant>PEAR_ERROR_RETURN</constant> If an error occurs, a + &class.pear-error; is returned from the error-generation + method (normally <link linkend="core.pear.pear.raiseerror"><function>raiseError</function></link>.) </para> </listitem> <listitem> <para> - <constant>PEAR_ERROR_PRINT</constant> Zoals <constant> - PEAR_ERROR_RETURN</constant>, maar een error bericht zal worden geprint. + <constant>PEAR_ERROR_PRINT</constant> Like <constant> + PEAR_ERROR_RETURN</constant>, but an error message will be + printed additionally. </para> </listitem> <listitem> <para> - <constant>PEAR_ERROR_TRIGGER</constant> Zoals <constant> - PEAR_ERROR_RETURN</constant>, maar de PHP ingebouwde-functie - <function>trigger_error</function> zal worden uitgevoerd. + <constant>PEAR_ERROR_TRIGGER</constant> Like <constant> + PEAR_ERROR_RETURN</constant>, but the PHP builtin-function + <function>trigger_error</function> will be called in PEAR_Error's + constructor with the error message. </para> </listitem> <listitem> <para> - <constant>PEAR_ERROR_DIE</constant> Het script zal worden beeindigd en een - error bericht zal worden geprint, als er een error is. + <constant>PEAR_ERROR_DIE</constant> The script will terminate and + an error message will be printed on instantiation of a PEAR_Error. </para> </listitem> <listitem> <para> - <constant>PEAR_ERROR_CALLBACK</constant> Als er een error is, zal de gegeven error handler functie - opgeroepen worden. Deze functie moet een parameter ondersteunen on het - &class.pear-error; object te kunnen verwerken. + <constant>PEAR_ERROR_CALLBACK</constant> If a error occurs, the + callback passed to <parameter>$options</parameter> is called. </para> </listitem> + <listitem> + <para> + <constant>PEAR_ERROR_EXCEPTION</constant> If Zend Engine 2 is present, + then an exception will be thrown using the &class.pear-error; object. + </para> + </listitem> </itemizedlist> </para> </listitem> <listitem> <para> - <parameter>mixed $options</parameter> - de waarde voor deze opties hangt van - <parameter>$mode</parameter> af + <parameter>mixed $options</parameter> - the value for <parameter>$options</parameter> + depends on <parameter>$mode</parameter> <itemizedlist> <listitem> <para> - <constant>PEAR_ERROR_PRINT</constant> en - <constant>PEAR_ERROR_DIE</constant> bevatten - een optionele <function>printf</function> formaat string om - tijdens het printen te gebruiken. + <constant>PEAR_ERROR_PRINT</constant> and + <constant>PEAR_ERROR_DIE</constant> support + an optional <function>printf</function> format string used + when printing the error message. This format string should contain + a single %s, which will be used to insert the error message into the + string. Use the string to enclose the error message with other + useful information not included in the error message prefix or + error message. </para> </listitem> <listitem> <para> - <constant>PEAR_ERROR_TRIGGER</constant> hangt af van een gebruikers - level indenticatie ( mogelijke constanten: <constant>E_USER_NOTICE</constant>, - <constant>E_USER_WARNING</constant> of - <constant>E_USER_ERROR</constant>). + <constant>PEAR_ERROR_TRIGGER</constant> requires an user error + level constant used by <function>trigger_error</function> (possible constants: <constant>E_USER_NOTICE</constant>, + <constant>E_USER_WARNING</constant> or + <constant>E_USER_ERROR</constant>). Note that if the error constant + is not one of these valid error constants, a PHP warning will be + triggered. </para> </listitem> <listitem> <para> - <constant>PEAR_ERROR_CALLBACK</constant> hangt af van de - indenticatie van de functie om een string, of, als - de functie een class member is, een array die de class naam en - functie naam bevat te verwerken. + <constant>PEAR_ERROR_CALLBACK</constant> The callback must be a function + name in the format described in the <ulink url="&url.php.callback;">Pseudo-Type</ulink> + section of the PHP manual (either a string, or an array). The callback must accept a single + parameter, the &class.pear-error; object generated by an error condition. + Note that if the callback is not a valid callback, a PHP warning will + be triggered. </para> </listitem> </itemizedlist> </para> </listitem> </itemizedlist> + </para> + <para> + Here's an example of a few ways to use setErrorHandling: + <programlisting role="php"> +<![CDATA[ +<?php +require_once 'PEAR.php'; +// dummy error constant for this example +define('MYCLASS_ERROR_CODE', 1); + +// demonstration of default global error handling +// in this case, all PEAR Errors will trigger a PHP warning +PEAR::setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_WARNING); +// Note that the file and line number will be in the constructor of PEAR_Error +// in PEAR.php +PEAR::raiseError('test warning', MYCLASS_ERROR_CODE); + +// this error specifies a mode, and overrides the default global error handling +$e = PEAR::raiseError('return only', MYCLASS_ERROR_CODE, PEAR_ERROR_RETURN); + +PEAR::setErrorHandling(PEAR_ERROR_PRINT, "Gronk error: %s<br />\n"); + +// prints "Gronk error: test warning<br />\n" +PEAR::raiseError('test warning', MYCLASS_ERROR_CODE); + +/** + * Fake class to demonstrate error handling + * @package myClass + */ +class myClass extends PEAR { + /** + * Demonstration of default local error handling + */ + function myClass() + { + // object method callback + $this->setErrorHandling(PEAR_ERROR_CALLBACK, array(&$this, 'handleErr')); + // prints "custom handler...is working" + PEAR::raiseError('custom handler', MYCLASS_ERROR_CODE); + // static class method callback + $this->setErrorHandling(PEAR_ERROR_CALLBACK, + array('myClass', 'handleErrStatic')); + PEAR::raiseError('custom handler', MYCLASS_ERROR_CODE); + // function callback + $this->setErrorHandling(PEAR_ERROR_CALLBACK, 'standardCallback'); + PEAR::raiseError('custom handler', MYCLASS_ERROR_CODE); + } + + /** + * Callback set by the constructor + * @param PEAR_Error The error object + */ + function handleErr($error) + { + $this->lastError = $error->getMessage(); + print $error->getMessage() . "...is working\n"; + } + + /** + * Static callback set by the constructor + * + * Note that in PHP 5, $this is not set if the method is declared with + * the "static" access modifier. In PHP 4, $this is set, but is not + * set to the myClass object, so don't use it! + * @param PEAR_Error The error object + */ + function handleErr($error) + { + print 'static ' . $error->getMessage() . "...is working\n"; + } +} + +/** + * @param PEAR_Error The error object + */ +function standardCallback($error) +{ + print 'normal function callback: ' . $error-getMessage(); +} +// This causes the printing of three messages through error callbacks: +// "custom handler...is working" +// "static custom handler... is working" +// "normal function callback: custom handler" +$mine = new myClass; + +PEAR::setErrorHandling(PEAR_ERROR_DIE); +// terminates the script with the error message "oops" +PEAR::raiseError('oops', MYCLASS_ERROR_CODE); +?> +]]> + </programlisting> </para> </refsect1> </refentry> Index: peardoc/nl/package/fileformats.xml diff -u peardoc/nl/package/fileformats.xml:1.1 peardoc/nl/package/fileformats.xml:1.2 --- peardoc/nl/package/fileformats.xml:1.1 Thu Aug 7 09:17:18 2003 +++ peardoc/nl/package/fileformats.xml Tue Aug 26 08:08:43 2003 @@ -7,7 +7,8 @@ &package.fileformats.mp3-id; &package.fileformats.spreadsheet-excel-writer; - + &package.fileformats.file_dicom; + </chapter> <!-- Keep this comment at the end of the file Local variables:
« previous php.pear.doc (#1411) next »