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