]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Query/Tree/Error.hs
[hyperdata] refactor code to add hyperdata graph metrics
[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 FlexibleContexts #-}
13 {-# LANGUAGE NoImplicitPrelude #-}
14 {-# LANGUAGE OverloadedStrings #-}
15 {-# LANGUAGE QuasiQuotes #-}
16 {-# LANGUAGE RankNTypes #-}
17
18 module Gargantext.Database.Query.Tree.Error
19 where
20
21 import Control.Lens (Prism', (#))
22 import Control.Monad.Error.Class (MonadError(throwError))
23 import Gargantext.Prelude
24
25 ------------------------------------------------------------------------
26 data TreeError = NoRoot
27 | EmptyRoot
28 | TooManyRoots
29
30 instance Show TreeError
31 where
32 show NoRoot = "Root node not found"
33 show EmptyRoot = "Root node should not be empty"
34 show TooManyRoots = "Too many root nodes"
35
36 class HasTreeError e where
37 _TreeError :: Prism' e TreeError
38
39 treeError :: ( MonadError e m
40 , HasTreeError e)
41 => TreeError
42 -> m a
43 treeError te = throwError $ _TreeError # te
44