]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Query/Tree/Error.hs
Merge branch '111-dev-refactor-text-corpus-api-with-conduit-alp' of ssh://gitlab...
[gargantext.git] / src / Gargantext / Database / Query / Tree / Error.hs
1 {-|
2 Module : Gargantext.Database.Tree.Error
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12 {-# LANGUAGE QuasiQuotes #-}
13
14 module Gargantext.Database.Query.Tree.Error
15 where
16
17 import Control.Lens (Prism', (#))
18 import Control.Monad.Except (MonadError(throwError))
19
20 import Gargantext.Prelude
21
22 ------------------------------------------------------------------------
23 data TreeError = NoRoot
24 | EmptyRoot
25 | TooManyRoots
26
27 instance Show TreeError
28 where
29 show NoRoot = "Root node not found"
30 show EmptyRoot = "Root node should not be empty"
31 show TooManyRoots = "Too many root nodes"
32
33 class HasTreeError e where
34 _TreeError :: Prism' e TreeError
35
36 treeError :: ( MonadError e m
37 , HasTreeError e )
38 => TreeError
39 -> m a
40 treeError te = throwError $ _TreeError # te
41