diff options
author | Joel Uckelman <uckelman@nomic.net> | 2012-02-27 04:56:10 +0100 |
---|---|---|
committer | Joel Uckelman <uckelman@nomic.net> | 2012-02-27 04:56:10 +0100 |
commit | 8f10606385c6e0a77177e48d4072b5eb7c52da68 (patch) | |
tree | 79b308352c0569bb01ca5228b864ec644b4ec3a1 /src/HTTP_POST_multipart.php | |
parent | b62a32659d64c76ffbdea8072f19d77915800c86 (diff) |
Fixed problem with expected exceptions.
Diffstat (limited to 'src/HTTP_POST_multipart.php')
-rw-r--r-- | src/HTTP_POST_multipart.php | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/HTTP_POST_multipart.php b/src/HTTP_POST_multipart.php index a3faa27..ad80cb9 100644 --- a/src/HTTP_POST_multipart.php +++ b/src/HTTP_POST_multipart.php @@ -25,8 +25,12 @@ class HTTP_POST_multipart { protected $_parts = array(); public function addData($name, $data) { - if ($name === null) throw new Exception('name is null'); - if ($data === null) throw new Exception('data is null'); + if ($name === null) { + throw new InvalidArgumentException('name is null'); + } + if ($data === null) { + throw new InvalidArgumentException('data is null'); + } $this->_parts[] = array( 'name' => $name, @@ -36,10 +40,18 @@ class HTTP_POST_multipart { public function addFile($name, $filename, $mimetype, $charset, $encoding, $data) { - if ($name === null) throw new Exception('name is null'); - if ($filename === null) throw new Exception('filename is null'); - if ($mimetype === null) throw new Exception('mimetype is null'); - if ($data === null) throw new Exception('data is null'); + if ($name === null) { + throw new InvalidArgumentException('name is null'); + } + if ($filename === null) { + throw new InvalidArgumentException('filename is null'); + } + if ($mimetype === null) { + throw new InvalidArgumentException('mimetype is null'); + } + if ($data === null) { + throw new InvalidArgumentException('data is null'); + } $this->_parts[] = array( 'name' => $name, @@ -82,7 +94,7 @@ class HTTP_POST_multipart { $data = chunk_split(base64_encode($part['data'])); break; default: - throw new Exception('unrecognized encoding: ' . $part['encoding']); + throw new InvalidArgumentException('unrecognized encoding: ' . $part['encoding']); } } else { |