getTemporaryDirectory: be more precise when catching exns from getEnv
authorSimon Marlow <simonmar@microsoft.com>
Mon, 18 Feb 2008 12:29:08 +0000 (12:29 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Mon, 18 Feb 2008 12:29:08 +0000 (12:29 +0000)
System/Directory.hs

index 80a20ee..d705c0d 100644 (file)
@@ -1027,7 +1027,10 @@ getTemporaryDirectory = do
      r <- c_GetTempPath (fromIntegral long_path_size) pPath
      peekCString pPath
 #else
-  catch (getEnv "TMPDIR") (\ex -> return "/tmp")
+  getEnv "TMPDIR"
+    `catch` \ex -> case ex of
+                     IOException e | isDoesNotExistError e -> return "/tmp"
+                     _ -> throw ex
 #endif
 
 #if defined(mingw32_HOST_OS)