mdref.json config
[mdref/mdref-http] / http / Exception.md
index 7c1865523ece4a5a4bc5c334810aee3b6326edc7..e27b813185bbfc59de507031979b8718b61a8ec4 100644 (file)
@@ -1,3 +1,29 @@
-# class http\Exception extends Exception
+# interface http\Exception
 
-The http extension's Exception.
+The http extension's Exception interface.
+
+Use it to catch any Exception thrown by pecl/http.
+
+The individual exception classes extend their equally named native PHP extensions, if such exist, and implement this empty interface. For example the http\Exception\BadMethodCallException extends SPL's BadMethodCallException.
+
+## Properties:
+
+None.
+
+## Example:
+
+    <?php
+    $req = new http\Env\Request;
+    
+    try {
+        $messages = $req->splitMultipartBody();
+    } catch (http\Exception\BadMethodCallException $e) {
+        // doh, no multipart message
+    } catch (http\Exception\BadMessageException $e) {
+        // failure while parsing
+    } catch (http\Exception $e) {
+        // here we used the interface to catch any http\Exception
+    } catch (Exception $e) {
+        // catch any other exception (unlikely, though)
+    }
+    ?>