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
b29d0b5c
Commit
b29d0b5c
authored
Dec 04, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report panic for the old error format as well
parent
9a2f05e0
Pipeline
#5425
passed with stages
in 96 minutes and 20 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
Server.hs
src/Gargantext/API/Server.hs
+21
-1
No files found.
src/Gargantext/API/Server.hs
View file @
b29d0b5c
...
...
@@ -36,6 +36,8 @@ import Gargantext.System.Logging
import
Paths_gargantext
qualified
as
PG
-- cabal magic build module
import
Servant
import
Servant.Swagger.UI
(
swaggerSchemaUIServer
)
import
qualified
Data.ByteString.Lazy
as
BL
import
qualified
Data.Text.Encoding
as
TE
serverGargAPI
::
Text
->
ServerT
GargAPI
(
GargM
Env
BackendInternalError
)
...
...
@@ -70,7 +72,7 @@ server env = do
:<|>
frontEndServer
where
transformJSON
::
forall
a
.
GargErrorScheme
->
GargM
Env
BackendInternalError
a
->
Handler
a
transformJSON
GES_old
=
Handler
.
withExceptT
showAsServantJSONErr
.
(`
runReaderT
`
env
)
transformJSON
GES_old
=
Handler
.
withExceptT
showAsServantJSONErr
.
(`
runReaderT
`
env
)
.
logPanicErrors
transformJSON
GES_new
=
Handler
.
withExceptT
(
frontendErrorToServerError
.
backendErrorToFrontendError
)
.
(`
runReaderT
`
env
)
.
handlePanicErrors
handlePanicErrors
::
GargM
Env
BackendInternalError
a
->
GargM
Env
BackendInternalError
a
...
...
@@ -82,5 +84,23 @@ handlePanicErrors h = h `catch` handleSomeException
=
do
$
(
logLocM
)
ERROR
$
T
.
pack
$
displayException
ex
ReaderT
$
\
_
->
ExceptT
$
pure
$
Left
$
InternalUnexpectedError
se
|
Just
(
ber
::
BackendInternalError
)
<-
fromException
se
=
throwError
ber
-- re-throw the uncaught exception via the 'MonadError' instance
|
otherwise
=
throwM
se
-- re-throw the uncaught exception.
-- | Old compat-shim for the old error format, it just logs the exception properly
-- but otherwise rethrows it /without/ the stacktrace (to not leak internal details).
logPanicErrors
::
GargM
Env
BackendInternalError
a
->
GargM
Env
BackendInternalError
a
logPanicErrors
h
=
h
`
catch
`
handleSomeException
where
handleSomeException
::
SomeException
->
GargM
Env
BackendInternalError
a
handleSomeException
se
|
Just
ex
@
(
WithStacktrace
_
(
UnexpectedPanic
uex
))
<-
fromException
se
=
do
$
(
logLocM
)
ERROR
$
T
.
pack
$
displayException
ex
throwError
$
InternalServerError
$
err500
{
errBody
=
BL
.
fromStrict
$
TE
.
encodeUtf8
uex
}
|
Just
(
ber
::
BackendInternalError
)
<-
fromException
se
=
throwError
ber
-- re-throw the uncaught exception via the 'MonadError' instance
|
otherwise
=
throwM
se
-- re-throw the uncaught exception.
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