diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-01 17:52:29 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-01 17:52:29 -0400 |
commit | 4933128850879f0e0590746b6742dafcf857e113 (patch) | |
tree | 9932c4f25e97d7fcc2f8f7165644212565a0247d /core | |
parent | 2201074e1f1e4ec3c2f60cac74d8168738d83650 (diff) | |
download | nextcloud-server-4933128850879f0e0590746b6742dafcf857e113.tar.gz nextcloud-server-4933128850879f0e0590746b6742dafcf857e113.zip |
Throw exceptions in share API for UI to display
Diffstat (limited to 'core')
-rw-r--r-- | core/ajax/share.php | 10 | ||||
-rw-r--r-- | core/js/share.js | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php index 6f5b927c779..f7a41aa3a4a 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -25,9 +25,13 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['item'] switch ($_POST['action']) { case 'share': if (isset($_POST['shareType']) && isset($_POST['shareWith']) && isset($_POST['permissions'])) { - $return = OCP\Share::share($_POST['itemType'], $_POST['item'], $_POST['shareType'], $_POST['shareWith'], $_POST['permissions']); - // TODO May need to return private link - ($return) ? OC_JSON::success() : OC_JSON::error(); + try { + OCP\Share::share($_POST['itemType'], $_POST['item'], $_POST['shareType'], $_POST['shareWith'], $_POST['permissions']); + // TODO May need to return private link + OC_JSON::success(); + } catch (Exception $exception) { + OC_JSON::error(array('data' => array('message' => $exception->getMessage()))); + } } break; case 'unshare': diff --git a/core/js/share.js b/core/js/share.js index 5832acfd454..a3fe0f69732 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -47,7 +47,7 @@ OC.Share={ callback(result.data); } } else { - OC.dialogs.alert('Error', 'Error while sharing'); + OC.dialogs.alert(result.data.message, 'Error while sharing'); } }); }, |