]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Query/Tree/Error.hs
[phylo] filter threshold change
[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.Error.Class (MonadError(throwError))
19 import Gargantext.Prelude
20
21 ------------------------------------------------------------------------
22 data TreeError = NoRoot
23 | EmptyRoot
24 | TooManyRoots
25
26 instance Show TreeError
27 where
28 show NoRoot = "Root node not found"
29 show EmptyRoot = "Root node should not be empty"
30 show TooManyRoots = "Too many root nodes"
31
32 class HasTreeError e where
33 _TreeError :: Prism' e TreeError
34
35 treeError :: ( MonadError e m
36 , HasTreeError e)
37 => TreeError
38 -> m a
39 treeError te = throwError $ _TreeError # te
40