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
59619a80
Commit
59619a80
authored
Jul 16, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFACT] fix error messages
parent
565c8b01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
17 deletions
+14
-17
Node.hs
src/Gargantext/Database/Action/Node.hs
+3
-2
Share.hs
src/Gargantext/Database/Action/Share.hs
+8
-7
Error.hs
src/Gargantext/Database/Query/Table/Node/Error.hs
+3
-8
No files found.
src/Gargantext/Database/Action/Node.hs
View file @
59619a80
...
...
@@ -44,6 +44,7 @@ mkNodeWithParent :: (HasNodeError err)
mkNodeWithParent
NodeUser
(
Just
_
)
_
_
=
nodeError
UserNoParent
------------------------------------------------------------------------
-- | MkNode, insert and eventually configure Hyperdata
mkNodeWithParent
NodeUser
Nothing
uId
name
=
insertNodesWithParentR
Nothing
[
node
NodeUser
name
defaultHyperdataUser
Nothing
uId
]
...
...
@@ -56,10 +57,10 @@ mkNodeWithParent NodeFrameCalc i u n =
mkNodeWithParent_ConfigureHyperdata
NodeFrameCalc
i
u
n
mkNodeWithParent
nt
(
Just
pId
)
uId
name
=
insertNode
nt
(
Just
name
)
Nothing
pId
uId
-- mkNodeWithParent _ _ _ _ = error
Msg
"[G.D.A.Node.mkNodeWithParent] nees parent"
-- mkNodeWithParent _ _ _ _ = error
With
"[G.D.A.Node.mkNodeWithParent] nees parent"
-- | Sugar to create a node, get
his NodeId and update hi
s Hyperdata after
-- | Sugar to create a node, get
its NodeId and update it
s Hyperdata after
mkNodeWithParent_ConfigureHyperdata
::
(
HasNodeError
err
)
=>
NodeType
->
Maybe
ParentId
...
...
src/Gargantext/Database/Action/Share.hs
View file @
59619a80
...
...
@@ -22,7 +22,7 @@ import Gargantext.Database.Admin.Types.Node (NodeId)
import
Gargantext.Database.Admin.Types.Node
-- (NodeType(..))
import
Gargantext.Database.Prelude
(
Cmd
)
import
Gargantext.Database.Query.Table.Node
(
getNode
,
getNodesWith
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
,
msg
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
,
errorWith
)
import
Gargantext.Database.Query.Table.NodeNode
(
insertNodeNode
,
deleteNodeNode
)
import
Gargantext.Database.Query.Tree.Root
(
getRootId
)
import
Gargantext.Database.Schema.Node
...
...
@@ -50,10 +50,10 @@ shareNodeWith (ShareNodeWith_User NodeFolderShared u) n = do
nodeToCheck
<-
getNode
n
userIdCheck
<-
getUserId
u
if
not
(
hasNodeType
nodeToCheck
NodeTeam
)
then
msg
"
Can share node Team only"
then
errorWith
"[G.D.A.S.shareNodeWith]
Can share node Team only"
else
if
(
view
node_userId
nodeToCheck
==
userIdCheck
)
then
msg
"
Can share to others only"
then
errorWith
"[G.D.A.S.shareNodeWith]
Can share to others only"
else
do
folderSharedId
<-
getFolderId
u
NodeFolderShared
insertNodeNode
[
NodeNode
folderSharedId
n
Nothing
Nothing
]
...
...
@@ -61,14 +61,15 @@ shareNodeWith (ShareNodeWith_User NodeFolderShared u) n = do
shareNodeWith
(
ShareNodeWith_Node
NodeFolderPublic
nId
)
n
=
do
nodeToCheck
<-
getNode
n
if
not
(
isInNodeTypes
nodeToCheck
publicNodeTypes
)
then
msg
$
"Can share this nodesTypes only: "
<>
(
cs
$
show
publicNodeTypes
)
then
errorWith
$
"[G.D.A.S.shareNodeWith] Can share this nodesTypes only: "
<>
(
cs
$
show
publicNodeTypes
)
else
do
folderToCheck
<-
getNode
nId
if
hasNodeType
folderToCheck
NodeFolderPublic
then
insertNodeNode
[
NodeNode
nId
n
Nothing
Nothing
]
else
msg
"
Can share NodeWith NodeFolderPublic only"
else
errorWith
"[G.D.A.S.shareNodeWith]
Can share NodeWith NodeFolderPublic only"
shareNodeWith
_
_
=
msg
"shareNodeWith n
ot implemented for this NodeType"
shareNodeWith
_
_
=
errorWith
"[G.D.A.S.shareNodeWith] N
ot implemented for this NodeType"
------------------------------------------------------------------------
getFolderId
::
HasNodeError
err
=>
User
->
NodeType
->
Cmd
err
NodeId
...
...
@@ -76,7 +77,7 @@ getFolderId u nt = do
rootId
<-
getRootId
u
s
<-
getNodesWith
rootId
HyperdataAny
(
Just
nt
)
Nothing
Nothing
case
head
s
of
Nothing
->
msg
"
No folder shared found"
Nothing
->
errorWith
"[G.D.A.S.getFolderId]
No folder shared found"
Just
f
->
pure
(
_node_id
f
)
------------------------------------------------------------------------
...
...
src/Gargantext/Database/Query/Table/Node/Error.hs
View file @
59619a80
...
...
@@ -58,20 +58,15 @@ instance Show NodeError
show
ManyNodeUsers
=
"Many userNode/user"
show
(
DoesNotExist
n
)
=
"Node does not exist"
<>
show
n
show
NeedsConfiguration
=
"Needs configuration"
show
(
NodeError
e
)
=
"NodeError: "
<>
cs
e
show
(
NodeError
e
)
=
"NodeError: "
<>
cs
e
class
HasNodeError
e
where
_NodeError
::
Prism'
e
NodeError
error
Msg
::
(
MonadError
e
m
error
With
::
(
MonadError
e
m
,
HasNodeError
e
)
=>
Text
->
m
a
errorMsg
=
msg
msg
::
(
MonadError
e
m
,
HasNodeError
e
)
=>
Text
->
m
a
msg
x
=
nodeError
(
NodeError
x
)
errorWith
x
=
nodeError
(
NodeError
x
)
nodeError
::
(
MonadError
e
m
,
HasNodeError
e
)
...
...
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