diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-02-03 00:23:12 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-02-03 00:23:12 +0100 |
commit | cb52a4cdc2daa45a61c728f5ec83603e6c6a71fa (patch) | |
tree | 0470c7a3d39c41f6b2b87af8fc8700ad849e14cf /application/service | |
parent | 33efe571e3e7ebd607e92345c2e94e7fd8ae27f0 (diff) |
Rework error handling in upload validator
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/service')
-rw-r--r-- | application/service/files.php | 8 | ||||
-rw-r--r-- | application/service/user.php | 1 |
2 files changed, 5 insertions, 4 deletions
diff --git a/application/service/files.php b/application/service/files.php index 8d8b1d01a..c270500ef 100644 --- a/application/service/files.php +++ b/application/service/files.php @@ -89,6 +89,10 @@ class files { $CI =& get_instance(); $errors = array(); + if (empty($files)) { + throw new \exceptions\UserInputException("file/no-file", "No file was uploaded or unknown error occured."); + } + foreach ($files as $key => $file) { $error_message = ""; @@ -113,7 +117,6 @@ class files { } else { $error_message = "Unknown error code: ".$file['error'].". Please report a bug."; } - } $filesize = filesize($file['tmp_name']); @@ -127,9 +130,8 @@ class files { "formfield" => $file["formfield"], "message" => $error_message, ); + throw new \exceptions\FileUploadVerifyException("file/upload-verify", "Failed to verify uploaded file(s)", $errors); } } - - return $errors; } } diff --git a/application/service/user.php b/application/service/user.php index 97f2531f9..16fa62272 100644 --- a/application/service/user.php +++ b/application/service/user.php @@ -23,7 +23,6 @@ class user { { $CI =& get_instance(); - $valid_levels = $CI->muser->get_access_levels(); if (array_search($access_level, $valid_levels) === false) { throw new \exceptions\UserInputException("user/validation/access_level/invalid", "Invalid access levels requested."); |