Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Przemyslaw Kaminski
haskell-gargantext
Commits
385d4328
Commit
385d4328
authored
Jan 04, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[HANDLING] Error, prism for ServantErr.
parent
2fb1a0fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
4 deletions
+10
-4
Node.hs
src/Gargantext/API/Node.hs
+3
-3
Node.hs
src/Gargantext/Database/Schema/Node.hs
+1
-1
Utils.hs
src/Gargantext/Database/Utils.hs
+6
-0
No files found.
src/Gargantext/API/Node.hs
View file @
385d4328
...
...
@@ -267,7 +267,7 @@ graphAPI nId = do
-- TODO what do we get about the node? to replace contextText
instance
HasNodeError
ServantErr
where
_NodeError
=
prism'
mk
(
const
$
panic
"HasNodeError ServantErr: not a prism"
)
_NodeError
=
prism'
mk
(
const
Nothing
)
--
$ panic "HasNodeError ServantErr: not a prism")
where
e
=
"NodeError: "
mk
NoListFound
=
err404
{
errBody
=
e
<>
"No list found"
}
...
...
@@ -276,7 +276,7 @@ instance HasNodeError ServantErr where
mk
NoUserFound
=
err404
{
errBody
=
e
<>
"No User found"
}
mk
MkNode
=
err500
{
errBody
=
e
<>
"Cannot mk node"
}
mk
NegativeId
=
err500
{
errBody
=
e
<>
"Node
Id non positive"
}
mk
NegativeId
=
err500
{
errBody
=
e
<>
"Node
with negative Id"
}
mk
UserNoParent
=
err500
{
errBody
=
e
<>
"Should not have parent"
}
mk
HasParent
=
err500
{
errBody
=
e
<>
"NodeType has parent"
}
mk
NotImplYet
=
err500
{
errBody
=
e
<>
"Not implemented yet"
}
...
...
@@ -285,7 +285,7 @@ instance HasNodeError ServantErr where
-- TODO(orphan): There should be a proper APIError data type with a case TreeError.
instance
HasTreeError
ServantErr
where
_TreeError
=
prism'
mk
(
const
$
panic
"HasTreeError ServantErr: not a prism"
)
_TreeError
=
prism'
mk
(
const
Nothing
)
--
$ panic "HasTreeError ServantErr: not a prism")
where
e
=
"TreeError: "
mk
NoRoot
=
err404
{
errBody
=
e
<>
"Root node not found"
}
...
...
src/Gargantext/Database/Schema/Node.hs
View file @
385d4328
...
...
@@ -526,7 +526,7 @@ mkCorpus n h p u = insertNodesR [nodeCorpusW n h p u]
getOrMkList
::
HasNodeError
err
=>
ParentId
->
UserId
->
Cmd
err
Int
getOrMkList
pId
uId
=
defaultList
pId
`
catchNodeError
`
(
\
_
->
maybe
(
nodeError
MkNode
)
pure
.
headMay
=<<
mkList
pId
uId
)
(
\
x
->
maybe
(
nodeError
x
)
pure
.
headMay
=<<
mkList
pId
uId
)
defaultList
::
HasNodeError
err
=>
CorpusId
->
Cmd
err
ListId
defaultList
cId
=
...
...
src/Gargantext/Database/Utils.hs
View file @
385d4328
...
...
@@ -37,6 +37,7 @@ import Database.PostgreSQL.Simple.FromField ( Conversion, ResultError(Conversion
import
Database.PostgreSQL.Simple.Internal
(
Field
)
import
Gargantext.Prelude
import
Opaleye
(
Query
,
Unpackspec
,
showSqlForPostgres
,
FromFields
,
Select
,
runQuery
)
import
Servant
(
ServantErr
)
import
System.IO
(
FilePath
)
import
Text.Read
(
read
)
import
qualified
Data.ByteString
as
DB
...
...
@@ -72,6 +73,11 @@ runCmdDev f = do
conn
<-
connectGargandb
"gargantext.ini"
either
(
fail
.
show
)
pure
=<<
runCmd
conn
f
runCmdDev'
::
Cmd
ServantErr
a
->
IO
a
runCmdDev'
f
=
do
conn
<-
connectGargandb
"gargantext.ini"
either
(
fail
.
show
)
pure
=<<
runCmd
conn
f
-- Use only for dev
runCmdDevNoErr
::
Cmd
()
a
->
IO
a
runCmdDevNoErr
=
runCmdDev
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment