]> Git — Sourcephile - gargantext.git/blob - bin/gargantext-client/Core.hs
[conduit] some refactoring
[gargantext.git] / bin / gargantext-client / Core.hs
1 module Core (problem, whenVerbose) where
2
3 import Options
4 import Options.Generic
5
6 import Control.Exception
7 import Control.Monad
8 import Control.Monad.Catch
9 import Servant.Client
10
11 newtype GargClientException = GCE String
12 instance Show GargClientException where
13 show (GCE s) = "Garg client exception: " ++ s
14
15 instance Exception GargClientException
16
17 -- | Abort with a message
18 problem :: String -> ClientM a
19 problem = throwM . GCE
20
21 -- | Only run the given computation when the @--verbose@ flag is
22 -- passed.
23 whenVerbose :: Monad m => ClientOpts -> m () -> m ()
24 whenVerbose opts act = when (unHelpful $ verbose opts) act