diff --git a/core/includes/file.inc b/core/includes/file.inc
index c3454e6..9446a71 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -5,8 +5,6 @@
  * API for handling file uploads and server file management.
  */
 
-use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 use Symfony\Component\HttpFoundation\StreamedResponse;
 use Drupal\Core\StreamWrapper\LocalStream;
 
@@ -2049,7 +2047,7 @@ function file_download() {
       $function = $module . '_file_download';
       $result = $function($uri);
       if ($result == -1) {
-        throw new AccessDeniedHttpException();
+        return drupal_access_denied();
       }
       if (isset($result) && is_array($result)) {
         $headers = array_merge($headers, $result);
@@ -2067,9 +2065,9 @@ function file_download() {
         }
       }, 200, $headers);
     }
-    throw new AccessDeniedHttpException();
+    return drupal_access_denied();
   }
-  throw new NotFoundHttpException();
+  return drupal_not_found();
 }
 
 
