Wrong response logging with custom error handler
See original GitHub issueWrong response logging with custom error handler
If server use custom error formatter in logs we don’t see correct response. Code for reproduce: https://github.com/witem/actionhero/commit/554153c07e8245b856848fee62b2536e97ec44fc .
When I run curl http://localhost:8080/api/testAppErr
, receive:
"error": {
"code": "100500",
"message": "some app error"
},
But in console:
error: [ action @ web ] to=127.0.0.1 action=testAppErr params={"action":"testAppErr","apiVersion":1} duration=3 error=AppError: some app error response={"error":{"name":"AppError","appCode":"100500"}} name=AppError appCode=100500 stack=AppError: some app error
at TestAppError.run (/home/ark/projects/git-projects/actionhero/src/actions/randomNumber.ts:43:17)
at ActionProcessor.runAction (/home/ark/projects/git-projects/actionhero/src/classes/actionProcessor.ts:381:35)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at WebServer.processAction (/home/ark/projects/git-projects/actionhero/src/classes/server.ts:229:18)
When I run curl http://localhost:8080/api/testErr
, receive:
"error": {
"code": 500,
"message": "Internal server error"
}
But in console:
error: [ action @ web ] to=127.0.0.1 action=testAppErr params={"action":"testAppErr","apiVersion":1} duration=2 error=AppError: some app error response={"error":{"name":"AppError","code":"100500"}} name=AppErro
r code=100500 stack=AppError: some app error
at TestAppError.run (/home/ark/projects/git-projects/actionhero/src/actions/randomNumber.ts:43:17)
at ActionProcessor.runAction (/home/ark/projects/git-projects/actionhero/src/classes/actionProcessor.ts:381:35)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at WebServer.processAction (/home/ark/projects/git-projects/actionhero/src/classes/server.ts:229:18)
- Actionhero Version:
23.0.0
- Node.js Version:
12.18.0
- Operating System:
Manjaro 5.7.0
Steps to reproduce your error
Example changes in: https://github.com/witem/actionhero/commit/554153c07e8245b856848fee62b2536e97ec44fc
curl http://localhost:8080/api/testAppErr
curl http://localhost:8080/api/testErr
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (15 by maintainers)
Top Results From Across the Web
Error handling - Apollo GraphQL Docs
Making errors actionable on the client and server · Built-in error codes · Custom errors · Throwing errors · Omitting or including stacktrace...
Read more >Centralized Error Response Handling and a Custom Error ...
This article presents an implementation strategy to create a custom JSON, HTML, or text error page, via a centralized error response ...
Read more >Custom Error Message Handling for REST API - Baeldung
In this tutorial, we'll discuss how to implement a global error handler for a Spring REST API. We will use the semantics of...
Read more >Get Started with Custom Error Handling in Spring Boot (Java)
Learn how to implement custom error handling logic in Spring Boot. You will see two approaches based on the @ControllerAdvice annotation.
Read more >Handle errors in ASP.NET Core | Microsoft Learn
To configure a custom error handling page for the Production environment, call UseExceptionHandler. This exception handling middleware:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@evantahler yeah! Seems it work, thanks!
@witem thanks for the clarification!