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