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
37c94f6c
Commit
37c94f6c
authored
Nov 06, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InternalServerError -> FrontendError
parent
2730e32c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
Errors.hs
src/Gargantext/API/Errors.hs
+9
-2
Types.hs
src/Gargantext/API/Errors/Types.hs
+27
-0
Backend.hs
src/Gargantext/API/Errors/Types/Backend.hs
+2
-0
No files found.
src/Gargantext/API/Errors.hs
View file @
37c94f6c
...
...
@@ -29,6 +29,8 @@ import Servant.Server
import
qualified
Data.Aeson
as
JSON
import
qualified
Data.Text
as
T
import
qualified
Network.HTTP.Types.Status
as
HTTP
import
qualified
Data.Text.Lazy.Encoding
as
TE
import
qualified
Data.Text.Lazy
as
TL
$
(
deriveHttpStatusCode
''
B
ackendErrorCode
)
...
...
@@ -48,11 +50,16 @@ backendErrorToFrontendError = \case
Just
v
->
T
.
pack
v
InternalAuthenticationError
authError
->
authErrorToFrontendError
authError
InternalServerError
_
internalServerError
->
undefined
InternalServerError
internalServerError
->
internalServerErrorToFrontendError
internalServerError
InternalJobError
jobError
->
jobErrorToFrontendError
jobError
internalServerErrorToFrontendError
::
ServerError
->
FrontendError
internalServerErrorToFrontendError
=
\
case
ServerError
{
..
}
->
mkFrontendErr'
(
T
.
pack
errReasonPhrase
)
$
FE_internal_server_error
(
TL
.
toStrict
$
TE
.
decodeUtf8
$
errBody
)
jobErrorToFrontendError
::
JobError
->
FrontendError
jobErrorToFrontendError
=
\
case
InvalidIDType
idTy
->
mkFrontendErrNoDiagnostic
$
FE_job_error_invalid_id_type
idTy
...
...
src/Gargantext/API/Errors/Types.hs
View file @
37c94f6c
...
...
@@ -246,6 +246,10 @@ data instance ToFrontendErrorData 'EC_500__job_error_unknown_job =
FE_job_error_unknown_job
{
jeuj_job_id
::
Int
}
deriving
(
Show
,
Eq
,
Generic
)
data
instance
ToFrontendErrorData
'E
C
_500__internal_server_error
=
FE_internal_server_error
{
ise_error
::
T
.
Text
}
deriving
(
Show
,
Eq
,
Generic
)
data
instance
ToFrontendErrorData
'E
C
_500__job_error_generic_exception
=
FE_job_error_generic_exception
{
jege_error
::
T
.
Text
}
deriving
(
Show
,
Eq
,
Generic
)
...
...
@@ -316,6 +320,19 @@ instance FromJSON (ToFrontendErrorData 'EC_403__login_failed_error) where
lfe_node_id
<-
o
.:
"node_id"
pure
FE_login_failed_error
{
..
}
--
-- internal server errors
--
instance
ToJSON
(
ToFrontendErrorData
'E
C
_500__internal_server_error
)
where
toJSON
FE_internal_server_error
{
..
}
=
object
[
"error"
.=
toJSON
ise_error
]
instance
FromJSON
(
ToFrontendErrorData
'E
C
_500__internal_server_error
)
where
parseJSON
=
withObject
"FE_internal_server_error"
$
\
o
->
do
ise_error
<-
o
.:
"error"
pure
FE_internal_server_error
{
..
}
--
-- tree errors
--
...
...
@@ -427,6 +444,11 @@ genFrontendErr be = do
uid
<-
arbitrary
pure
$
mkFrontendErr'
txt
$
FE_login_failed_error
nid
uid
-- internal error
EC_500__internal_server_error
->
do
err
<-
arbitrary
pure
$
mkFrontendErr'
txt
$
FE_internal_server_error
err
-- tree errors
EC_404__tree_error_root_not_found
->
pure
$
mkFrontendErr'
txt
$
FE_tree_error_root_not_found
...
...
@@ -500,6 +522,11 @@ instance FromJSON FrontendError where
(
fe_data
::
ToFrontendErrorData
'E
C
_403__login_failed_error
)
<-
o
.:
"data"
pure
FrontendError
{
..
}
-- internal server error
EC_500__internal_server_error
->
do
(
fe_data
::
ToFrontendErrorData
'E
C
_500__internal_server_error
)
<-
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"
...
...
src/Gargantext/API/Errors/Types/Backend.hs
View file @
37c94f6c
...
...
@@ -29,6 +29,8 @@ data BackendErrorCode
|
EC_404__tree_error_root_not_found
|
EC_404__tree_error_empty_root
|
EC_500__tree_error_too_many_roots
-- internal server errors
|
EC_500__internal_server_error
-- job errors
|
EC_500__job_error_invalid_id_type
|
EC_500__job_error_expired
...
...
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