2 Module : Gargantext.Database.Tree.Error
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 {-# LANGUAGE FlexibleContexts #-}
13 {-# LANGUAGE NoImplicitPrelude #-}
14 {-# LANGUAGE OverloadedStrings #-}
15 {-# LANGUAGE QuasiQuotes #-}
16 {-# LANGUAGE RankNTypes #-}
18 module Gargantext.Database.Query.Tree.Error
21 import Control.Lens (Prism', (#))
22 import Control.Monad.Error.Class (MonadError(throwError))
23 import Gargantext.Prelude
25 ------------------------------------------------------------------------
26 data TreeError = NoRoot
30 instance Show TreeError
32 show NoRoot = "Root node not found"
33 show EmptyRoot = "Root node should not be empty"
34 show TooManyRoots = "Too many root nodes"
36 class HasTreeError e where
37 _TreeError :: Prism' e TreeError
39 treeError :: ( MonadError e m
43 treeError te = throwError $ _TreeError # te