diff --git a/main/inc/lib/javascript/ckeditor/plugins/ckeditor_vimeo_embed/integration/upload.php b/main/inc/lib/javascript/ckeditor/plugins/ckeditor_vimeo_embed/integration/upload.php index 054e8d5568..7bd757a7cf 100644 --- a/main/inc/lib/javascript/ckeditor/plugins/ckeditor_vimeo_embed/integration/upload.php +++ b/main/inc/lib/javascript/ckeditor/plugins/ckeditor_vimeo_embed/integration/upload.php @@ -1,6 +1,8 @@ true, 'message' => get_lang('NotAllowed')]); + $message = get_lang('NotAllowed'); + + if (empty($config['access_token'])) { + $message = 'You can not upload a file without an access token. You can find this token on your app page.'; + } + + echo json_encode(['error' => true, 'message' => $message]); exit; } @@ -34,12 +42,6 @@ try { throw new Exception("File error ({$_FILES['ve_file']['error']})."); } - if (empty($config['access_token'])) { - throw new Exception( - 'You can not upload a file without an access token. You can find this token on your app page.' - ); - } - $vimeo = new Vimeo($config['client_id'], $config['client_secret'], $config['access_token']); $uri = $vimeo->upload( @@ -82,21 +84,7 @@ try { 'embed' => $embed, ] ); -} catch (VimeoUploadException $exception) { - echo json_encode( - [ - 'error' => true, - 'message' => $e->getMessage(), - ] - ); -} catch (VimeoRequestException $exception) { - echo json_encode( - [ - 'error' => true, - 'message' => $exception->getMessage(), - ] - ); -} catch (Exception $exception) { +} catch (VimeoUploadException|VimeoRequestException|Exception $exception) { echo json_encode( [ 'error' => true,