tmhedberg/hsenv — pull request #32 by adinapoli (2013-07-18 07:10:24+00:00)
Title: Fixes #23, second attempt :)

Ok, it should be *almost* there.

The only warty thing is, as you might notice, is that we call `error` when we fail. I've tried to stick to the project convention , doing something like:

```
case code -> throwError $ HsenvException $ bla bla bla
```

But I got an error which puzzles me:

```
src/Actions.hs:326:15:
Couldn't match type `GHC.IO.Exception.IOException'
with `HsenvException'
When using functional dependencies to combine
Control.Monad.Error.Class.MonadError
GHC.IO.Exception.IOException IO,
arising from the dependency `m -> e'
in the instance declaration in `Control.Monad.Error.Class'
Control.Monad.Error.Class.MonadError HsenvException IO,
arising from a use of `throwError' at src/Actions.hs:326:15-24
In the expression: throwError
In the expression:
throwError
$ HsenvException
$ "Failed to download "
++ name ++ ": http response returned " ++ show code
```

I suspect it's because we are lifting the whole computation from the IO, but I might be wrong. Insight and fixes are welcome. One quick to do would be to use `throw` instead of `throwError`, where the former lives inside `Control.Exception`. To do that, we also need to add an instance of `Exception` to `HsenvException`, which is a one liner:

```
instance Exception HsenvException
```

A.