@@ -390,8 +390,11 @@ execForeign env ctxt arity ty fn xs onfail
390390 ". Are all cases covered?"
391391 | Just (FFun "fileRemove" [(_,fileStr)] _) <- foreignFromTT arity ty fn xs
392392 = case fileStr of
393− EConstant (Str f) -> do execIO $ removeFile f
394− execApp env ctxt ioUnit (drop arity xs)
393+ EConstant (Str f) -> do res <- execIO $ catch (do removeFile f
394+ return $ ioWrap $ EConstant $ I 0)
395+ (\e -> do writeIORef fileError $ mapError e
396+ return $ ioWrap $ EConstant $ I (-1))
397+ execApp env ctxt res (drop arity xs)
395398 _ -> execFail . Msg $
396399 "The argument to fileRemove should be a constant string, but it was " ++
397400 show fileStr ++