question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong response logging with custom error handler

See original GitHub issue

Wrong 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:closed
  • Created 3 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
witemcommented, Nov 26, 2020

@evantahler yeah! Seems it work, thanks!

1reaction
gcoonrodcommented, Sep 12, 2020

@witem thanks for the clarification!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found