Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
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
gargantext
haskell-gargantext
Commits
0460c11e
Commit
0460c11e
authored
Nov 27, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add NodeParentDoesNotExist constructor to NodeLookupFailed
parent
8a464072
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
2 deletions
+50
-2
Errors.hs
src/Gargantext/API/Errors.hs
+2
-0
Types.hs
src/Gargantext/API/Errors/Types.hs
+18
-0
Backend.hs
src/Gargantext/API/Errors/Types/Backend.hs
+1
-0
Error.hs
src/Gargantext/Database/Query/Table/Node/Error.hs
+29
-2
No files found.
src/Gargantext/API/Errors.hs
View file @
0460c11e
...
...
@@ -113,6 +113,8 @@ nodeErrorToFrontendError ne = case ne of
->
case
reason
of
NodeDoesNotExist
nid
->
mkFrontendErrShow
$
FE_node_lookup_failed_not_found
nid
NodeParentDoesNotExist
nid
->
mkFrontendErrShow
$
FE_node_lookup_failed_parent_not_found
nid
UserDoesNotExist
uid
->
mkFrontendErrShow
$
FE_node_lookup_failed_user_not_found
uid
UserNameDoesNotExist
uname
...
...
src/Gargantext/API/Errors/Types.hs
View file @
0460c11e
...
...
@@ -192,6 +192,10 @@ newtype instance ToFrontendErrorData 'EC_404__node_lookup_failed_not_found =
FE_node_lookup_failed_not_found
{
nenf_node_id
::
NodeId
}
deriving
(
Show
,
Eq
,
Generic
)
newtype
instance
ToFrontendErrorData
'E
C
_404__node_lookup_failed_parent_not_found
=
FE_node_lookup_failed_parent_not_found
{
nepnf_node_id
::
NodeId
}
deriving
(
Show
,
Eq
,
Generic
)
newtype
instance
ToFrontendErrorData
'E
C
_404__node_lookup_failed_user_not_found
=
FE_node_lookup_failed_user_not_found
{
nenf_user_id
::
UserId
}
deriving
(
Show
,
Eq
,
Generic
)
...
...
@@ -352,6 +356,14 @@ instance FromJSON (ToFrontendErrorData 'EC_404__node_lookup_failed_not_found) wh
nenf_node_id
<-
o
.:
"node_id"
pure
FE_node_lookup_failed_not_found
{
..
}
instance
ToJSON
(
ToFrontendErrorData
'E
C
_404__node_lookup_failed_parent_not_found
)
where
toJSON
(
FE_node_lookup_failed_parent_not_found
nodeId
)
=
object
[
"node_id"
.=
toJSON
nodeId
]
instance
FromJSON
(
ToFrontendErrorData
'E
C
_404__node_lookup_failed_parent_not_found
)
where
parseJSON
=
withObject
"FE_node_lookup_failed_parent_not_found"
$
\
o
->
do
nepnf_node_id
<-
o
.:
"node_id"
pure
FE_node_lookup_failed_parent_not_found
{
..
}
instance
ToJSON
(
ToFrontendErrorData
'E
C
_404__node_lookup_failed_user_not_found
)
where
toJSON
(
FE_node_lookup_failed_user_not_found
userId
)
=
object
[
"user_id"
.=
toJSON
userId
]
...
...
@@ -581,6 +593,9 @@ genFrontendErr be = do
EC_404__node_lookup_failed_not_found
->
do
nodeId
<-
arbitrary
pure
$
mkFrontendErr'
txt
(
FE_node_lookup_failed_not_found
nodeId
)
EC_404__node_lookup_failed_parent_not_found
->
do
nodeId
<-
arbitrary
pure
$
mkFrontendErr'
txt
(
FE_node_lookup_failed_parent_not_found
nodeId
)
EC_404__node_lookup_failed_user_not_found
->
do
userId
<-
arbitrary
pure
$
mkFrontendErr'
txt
(
FE_node_lookup_failed_user_not_found
userId
)
...
...
@@ -693,6 +708,9 @@ instance FromJSON FrontendError where
EC_404__node_lookup_failed_not_found
->
do
(
fe_data
::
ToFrontendErrorData
'E
C
_404__node_lookup_failed_not_found
)
<-
o
.:
"data"
pure
FrontendError
{
..
}
EC_404__node_lookup_failed_parent_not_found
->
do
(
fe_data
::
ToFrontendErrorData
'E
C
_404__node_lookup_failed_parent_not_found
)
<-
o
.:
"data"
pure
FrontendError
{
..
}
EC_404__node_lookup_failed_user_not_found
->
do
(
fe_data
::
ToFrontendErrorData
'E
C
_404__node_lookup_failed_user_not_found
)
<-
o
.:
"data"
pure
FrontendError
{
..
}
...
...
src/Gargantext/API/Errors/Types/Backend.hs
View file @
0460c11e
...
...
@@ -19,6 +19,7 @@ data BackendErrorCode
EC_404__node_list_not_found
|
EC_404__node_root_not_found
|
EC_404__node_lookup_failed_not_found
|
EC_404__node_lookup_failed_parent_not_found
|
EC_400__node_lookup_failed_user_too_many_roots
|
EC_404__node_lookup_failed_user_not_found
|
EC_404__node_lookup_failed_username_not_found
...
...
src/Gargantext/Database/Query/Table/Node/Error.hs
View file @
0460c11e
...
...
@@ -9,7 +9,22 @@ Stability : experimental
Portability : POSIX
-}
module
Gargantext.Database.Query.Table.Node.Error
where
module
Gargantext.Database.Query.Table.Node.Error
(
-- * Types
NodeError
(
..
)
,
NodeCreationError
(
..
)
,
NodeLookupError
(
..
)
-- * Classes
,
HasNodeError
(
..
)
-- * Functions
,
errorWith
,
nodeError
,
nodeCreationError
,
nodeLookupError
,
catchNodeError
)
where
import
Control.Lens
(
Prism
'
,
(
#
),
(
^?
))
import
Data.Aeson
...
...
@@ -37,13 +52,15 @@ renderNodeCreationFailed = \case
data
NodeLookupError
=
NodeDoesNotExist
NodeId
|
NodeParentDoesNotExist
NodeId
|
UserDoesNotExist
UserId
|
UserNameDoesNotExist
Username
|
UserHasTooManyRoots
UserId
[
NodeId
]
renderNodeLookupFailed
::
NodeLookupError
->
T
.
Text
renderNodeLookupFailed
=
\
case
NodeDoesNotExist
nid
->
"node with id "
<>
T
.
pack
(
show
nid
)
<>
" couldn't be found."
NodeDoesNotExist
nid
->
"node with id "
<>
T
.
pack
(
show
nid
)
<>
" couldn't be found."
NodeParentDoesNotExist
nid
->
"no parent for node with id "
<>
T
.
pack
(
show
nid
)
<>
"."
UserDoesNotExist
uid
->
"user with id "
<>
T
.
pack
(
show
uid
)
<>
" couldn't be found."
UserNameDoesNotExist
uname
->
"user with username '"
<>
uname
<>
" couldn't be found."
UserHasTooManyRoots
uid
roots
->
"user with id "
<>
T
.
pack
(
show
uid
)
<>
" has too many roots: ["
<>
T
.
intercalate
","
(
map
(
T
.
pack
.
show
)
roots
)
...
...
@@ -97,5 +114,15 @@ nodeError :: ( MonadError e m
=>
NodeError
->
m
a
nodeError
ne
=
throwError
$
_NodeError
#
ne
nodeCreationError
::
(
MonadError
e
m
,
HasNodeError
e
)
=>
NodeCreationError
->
m
a
nodeCreationError
ne
=
throwError
$
_NodeError
#
NodeCreationFailed
ne
nodeLookupError
::
(
MonadError
e
m
,
HasNodeError
e
)
=>
NodeLookupError
->
m
a
nodeLookupError
ne
=
throwError
$
_NodeError
#
NodeLookupFailed
ne
catchNodeError
::
(
MonadError
e
m
,
HasNodeError
e
)
=>
m
a
->
(
NodeError
->
m
a
)
->
m
a
catchNodeError
f
g
=
catchError
f
(
\
e
->
maybe
(
throwError
e
)
g
(
e
^?
_NodeError
))
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