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
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
b44e4c16
Commit
b44e4c16
authored
Nov 06, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more cases to nodeErrorToFrontendError
parent
1573c5f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
3 deletions
+50
-3
Errors.hs
src/Gargantext/API/Errors.hs
+3
-3
Types.hs
src/Gargantext/API/Errors/Types.hs
+45
-0
Backend.hs
src/Gargantext/API/Errors/Types/Backend.hs
+2
-0
No files found.
src/Gargantext/API/Errors.hs
View file @
b44e4c16
...
...
@@ -66,11 +66,11 @@ nodeErrorToFrontendError ne = case ne of
NegativeId
->
undefined
NotImplYet
->
undefined
->
mkFrontendErrShow
FE_node_error_not_implemented_yet
ManyNodeUsers
->
undefined
DoesNotExist
_
nodeId
->
undefine
d
DoesNotExist
nodeId
->
mkFrontendErrShow
$
FE_node_error_not_found
nodeI
d
NoContextFound
_contextId
->
undefined
NeedsConfiguration
...
...
src/Gargantext/API/Errors/Types.hs
View file @
b44e4c16
...
...
@@ -180,12 +180,26 @@ data instance ToFrontendErrorData 'EC_404__node_error_corpus_not_found =
FE_node_error_corpus_not_found
deriving
(
Show
,
Eq
,
Generic
)
data
instance
ToFrontendErrorData
'E
C
_500__node_error_not_implemented_yet
=
FE_node_error_not_implemented_yet
deriving
(
Show
,
Eq
,
Generic
)
data
instance
ToFrontendErrorData
'E
C
_404__node_error_not_found
=
FE_node_error_not_found
{
nenf_node_id
::
!
NodeId
}
deriving
(
Show
,
Eq
,
Generic
)
--
-- Tree errors
--
data
instance
ToFrontendErrorData
'E
C
_404__tree_error_root_not_found
=
RootNotFound
{
_rnf_rootId
::
RootId
}
deriving
(
Show
,
Eq
,
Generic
)
----------------------------------------------------------------------------
-- JSON instances. It's important to have nice and human readable instances.
-- It's also important that they all roundtrips, i.e. that given a 'ToFrontendErrorData'
-- payload, we can render it to JSON and parse it back.
----------------------------------------------------------------------------
instance
ToJSON
(
ToFrontendErrorData
'E
C
_404__node_error_list_not_found
)
where
...
...
@@ -209,6 +223,20 @@ instance ToJSON (ToFrontendErrorData 'EC_404__node_error_corpus_not_found) where
instance
FromJSON
(
ToFrontendErrorData
'E
C
_404__node_error_corpus_not_found
)
where
parseJSON
_
=
pure
FE_node_error_corpus_not_found
instance
ToJSON
(
ToFrontendErrorData
'E
C
_500__node_error_not_implemented_yet
)
where
toJSON
_
=
JSON
.
Null
instance
FromJSON
(
ToFrontendErrorData
'E
C
_500__node_error_not_implemented_yet
)
where
parseJSON
_
=
pure
FE_node_error_not_implemented_yet
instance
ToJSON
(
ToFrontendErrorData
'E
C
_404__node_error_not_found
)
where
toJSON
(
FE_node_error_not_found
nodeId
)
=
object
[
"node_id"
.=
toJSON
nodeId
]
instance
FromJSON
(
ToFrontendErrorData
'E
C
_404__node_error_not_found
)
where
parseJSON
=
withObject
"FE_node_error_not_found"
$
\
o
->
do
nenf_node_id
<-
o
.:
"node_id"
pure
FE_node_error_not_found
{
..
}
instance
ToJSON
(
ToFrontendErrorData
'E
C
_404__tree_error_root_not_found
)
where
toJSON
RootNotFound
{
..
}
=
object
[
"root_id"
.=
toJSON
_rnf_rootId
]
...
...
@@ -228,12 +256,21 @@ genFrontendErr :: BackendErrorCode -> Gen FrontendError
genFrontendErr
be
=
do
txt
<-
arbitrary
case
be
of
-- node errors
EC_404__node_error_list_not_found
->
arbitrary
>>=
\
lid
->
pure
$
mkFrontendErr'
txt
$
FE_node_error_list_not_found
lid
EC_404__node_error_root_not_found
->
pure
$
mkFrontendErr'
txt
FE_node_error_root_not_found
EC_404__node_error_corpus_not_found
->
pure
$
mkFrontendErr'
txt
FE_node_error_corpus_not_found
EC_500__node_error_not_implemented_yet
->
pure
$
mkFrontendErr'
txt
FE_node_error_not_implemented_yet
EC_404__node_error_not_found
->
do
nodeId
<-
arbitrary
pure
$
mkFrontendErr'
txt
(
FE_node_error_not_found
nodeId
)
-- tree errors
EC_404__tree_error_root_not_found
->
do
rootId
<-
arbitrary
pure
$
mkFrontendErr'
txt
(
RootNotFound
rootId
)
...
...
@@ -268,6 +305,14 @@ instance FromJSON FrontendError where
EC_404__node_error_corpus_not_found
->
do
(
fe_data
::
ToFrontendErrorData
'E
C
_404__node_error_corpus_not_found
)
<-
o
.:
"data"
pure
FrontendError
{
..
}
EC_404__node_error_not_found
->
do
(
fe_data
::
ToFrontendErrorData
'E
C
_404__node_error_not_found
)
<-
o
.:
"data"
pure
FrontendError
{
..
}
-- tree errors
EC_404__tree_error_root_not_found
->
do
(
fe_data
::
ToFrontendErrorData
'E
C
_404__tree_error_root_not_found
)
<-
o
.:
"data"
pure
FrontendError
{
..
}
EC_500__node_error_not_implemented_yet
->
do
(
fe_data
::
ToFrontendErrorData
'E
C
_500__node_error_not_implemented_yet
)
<-
o
.:
"data"
pure
FrontendError
{
..
}
src/Gargantext/API/Errors/Types/Backend.hs
View file @
b44e4c16
...
...
@@ -18,7 +18,9 @@ data BackendErrorCode
-- node errors
EC_404__node_error_list_not_found
|
EC_404__node_error_root_not_found
|
EC_404__node_error_not_found
|
EC_404__node_error_corpus_not_found
|
EC_500__node_error_not_implemented_yet
-- tree errors
|
EC_404__tree_error_root_not_found
deriving
(
Show
,
Read
,
Eq
,
Enum
,
Bounded
)
...
...
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