diff --git a/lib/GHCup/Utils/File.hs b/lib/GHCup/Utils/File.hs
index a49fcde99825a0f69f6580295ffc614002464043..d212b509c136ce1bd6d1510532b7c5cc9b06749a 100644
--- a/lib/GHCup/Utils/File.hs
+++ b/lib/GHCup/Utils/File.hs
@@ -371,8 +371,7 @@ searchPath paths needle = go paths
  where
   go [] = pure Nothing
   go (x : xs) =
-    hideErrorDefM PermissionDenied (go xs)
-      $ hideErrorDefM NoSuchThing (go xs)
+    hideErrorDefM [InappropriateType, PermissionDenied, NoSuchThing] (go xs)
       $ do
           dirStream <- openDirStream (toFilePath x)
           S.findM (\(_, p) -> isMatch x p) (dirContentsStream dirStream)
diff --git a/lib/GHCup/Utils/Prelude.hs b/lib/GHCup/Utils/Prelude.hs
index 07acf14fedd07d1ffdb32583d8103e9065652f2e..7003bf1a683333dbadaa42310b9ff2054ea45d97 100644
--- a/lib/GHCup/Utils/Prelude.hs
+++ b/lib/GHCup/Utils/Prelude.hs
@@ -168,14 +168,14 @@ liftIOException errType ex =
     . lift
 
 
-hideErrorDef :: IOErrorType -> a -> IO a -> IO a
-hideErrorDef err def =
-  handleIO (\e -> if err == ioeGetErrorType e then pure def else ioError e)
+hideErrorDef :: [IOErrorType] -> a -> IO a -> IO a
+hideErrorDef errs def =
+  handleIO (\e -> if ioeGetErrorType e `elem` errs then pure def else ioError e)
 
 
-hideErrorDefM :: IOErrorType -> IO a -> IO a -> IO a
-hideErrorDefM err def =
-  handleIO (\e -> if err == ioeGetErrorType e then def else ioError e)
+hideErrorDefM :: [IOErrorType] -> IO a -> IO a -> IO a
+hideErrorDefM errs def =
+  handleIO (\e -> if ioeGetErrorType e `elem` errs then def else ioError e)
 
 
 -- TODO: does this work?