Use a monad for error reporting.