catchJust

catchJust :: (Exception -> Maybe b) -> IO a -> (b -> IO a) -> IO a
base Control.OldException
The function catchJust is like catch, but it takes an extra argument which is an exception predicate, a function which selects which type of exceptions we're interested in. There are some predefined exception predicates for useful subsets of exceptions: ioErrors, arithExceptions, and so on. For example, to catch just calls to the error function, we could use > result <- catchJust errorCalls thing_to_try handler Any other exceptions which are not matched by the predicate are re-raised, and may be caught by an enclosing catch or catchJust.
catchJust :: Exception e => (e -> Maybe b) -> IO a -> (b -> IO a) -> IO a
base Control.Exception.Base, base Control.Exception
The function catchJust is like catch, but it takes an extra argument which is an exception predicate, a function which selects which type of exceptions we're interested in. > catchJust (\e -> if isDoesNotExistErrorType (ioeGetErrorType e) then Just () else Nothing) > (readFile f) > (\_ -> do hPutStrLn stderr ("No such file: " ++ show f) > return "") Any other exceptions which are not matched by the predicate are re-raised, and may be caught by an enclosing catch, catchJust, etc.