try +cgi

tryCGI :: (MonadCGI m, MonadCatchIO m) => m a -> m (Either SomeException a)
cgi Network.CGI.Monad, cgi Network.CGI
Catches any exception thrown by an CGI action, and returns either the exception, or if no exception was raised, the result of the action.