diff --git a/repository/dropbox/classes/dropbox.php b/repository/dropbox/classes/dropbox.php index 3507c7a1fe3..81724b5c14c 100644 --- a/repository/dropbox/classes/dropbox.php +++ b/repository/dropbox/classes/dropbox.php @@ -177,7 +177,7 @@ class dropbox extends \oauth2_client { * This function attempts to deal with errors as per * https://www.dropbox.com/developers/documentation/http/documentation#error-handling. * - * @param string $data The returned content. + * @param mixed $data The returned content. * @throws moodle_exception */ protected function check_and_handle_api_errors($data) { @@ -197,8 +197,8 @@ class dropbox extends \oauth2_client { throw new authentication_exception('Authentication token expired'); break; case 409: - // Endpoint-specific error. Look to the response body for the specifics of the error. - throw new \coding_exception('Endpoint specific error: ' . $data); + // Endpoint-specific error. Look to the JSON response body for the specifics of the error. + throw new \coding_exception('Endpoint specific error: ' . $data->error_summary); break; case 429: // Your app is making too many requests for the given user or team and is being rate limited. Your app diff --git a/repository/dropbox/tests/api_test.php b/repository/dropbox/tests/api_test.php index b5e8d45aaf0..aad18cf6672 100644 --- a/repository/dropbox/tests/api_test.php +++ b/repository/dropbox/tests/api_test.php @@ -116,7 +116,7 @@ class repository_dropbox_api_testcase extends advanced_testcase { ], '409 http_code' => [ ['http_code' => 409], - 'Some data here', + json_decode('{"error": "Some value", "error_summary": "Some data here"}'), 'coding_exception', 'Endpoint specific error: Some data here', ],