mdref.json config
[mdref/mdref-http] / http / Exception.md
1 # interface http\Exception
2
3 The http extension's Exception interface.
4
5 Use it to catch any Exception thrown by pecl/http.
6
7 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.
8
9 ## Properties:
10
11 None.
12
13 ## Example:
14
15 <?php
16 $req = new http\Env\Request;
17
18 try {
19 $messages = $req->splitMultipartBody();
20 } catch (http\Exception\BadMethodCallException $e) {
21 // doh, no multipart message
22 } catch (http\Exception\BadMessageException $e) {
23 // failure while parsing
24 } catch (http\Exception $e) {
25 // here we used the interface to catch any http\Exception
26 } catch (Exception $e) {
27 // catch any other exception (unlikely, though)
28 }
29 ?>