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.

Exception in resolver not logged in terminal

See original GitHub issue

I’m submitting a…


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When throwing an exception from a resolver, it returns a GraphQL Error but it is not catched by the nestjs logger and noting is printed to the terminal.

@Resolver('Auth')
export class AuthResolver {
  constructor(
    private readonly authService: AuthService
  ) {}

  @Mutation(returns => User)
  @UseInterceptors(PictureInterceptor)
  async login(@Args() loginArgs: LoginArgs): Promise<User> {
    throw new Error('test ex');
    return this.authService.login(loginArgs)
  }

GraphQL Error Response:

"errors": [
    {
      "message": "test ex",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "login"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "Error: test ex",
            "    at AuthResolver.<anonymous> (/usr/src/app/src/shared/auth/auth.resolver.ts:27:11)",
            ...

Expected behavior

When throwing an Error from a controller, the error is captured by nestjs logger and printed to my terminal. I expect Error thrown in Resolver to be printed in the terminal as well like it is in controllers.

Example:

@Controller('pictures')
export class PictureUploadController {
  @Get('/')
  public get() {
    throw new Error('test get error');
  }

Result in the terminal:

web_1    | Error: test get error
web_1    |     at PictureUploadController.<anonymous> (/usr/src/app/src/shared/picture-upload/picture-upload.controller.ts:28:11)
web_1    |     at Generator.next (<anonymous>)
web_1    |     at /usr/src/app/src/shared/picture-upload/picture-upload.controller.ts:17:71
web_1    |     at new Promise (<anonymous>)
web_1    |     at __awaiter (/usr/src/app/src/shared/picture-upload/picture-upload.controller.ts:13:12)
web_1    |     at PictureUploadController.get (/usr/src/app/src/shared/picture-upload/picture-upload.controller.ts:24:16)
web_1    |     at /usr/src/app/node_modules/@nestjs/core/router/router-execution-context.js:37:29
web_1    |     at InterceptorsConsumer.intercept (/usr/src/app/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:10:20)
web_1    |     at /usr/src/app/node_modules/@nestjs/core/router/router-execution-context.js:45:60
web_1    |     at /usr/src/app/node_modules/@nestjs/core/router/router-proxy.js:8:23
web_1    |     at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
web_1    |     at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13)
web_1    |     at Route.dispatch (/usr/src/app/node_modules/express/lib/router/route.js:112:3)
web_1    |     at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
web_1    |     at /usr/src/app/node_modules/express/lib/router/index.js:281:22
web_1    |     at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)

Environment


[Nest Information]
platform-express version : 6.8.3
mongoose version         : 6.1.2
passport version         : 6.1.0
graphql version          : 6.5.3
common version           : 6.8.3
core version             : 6.8.3


 
For Tooling issues:
- Node version: 11.12.0  
- Platform:  macOS Mojave

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kamilmysliwieccommented, Oct 29, 2019

Please, provide a minimal repository which reproduces your issue.

0reactions
lock[bot]commented, Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - How to handle error in a Resolver - Stack Overflow
I have a few resolvers, all of which can experience exceptions on the server, But I don't know what to do in the...
Read more >
Handling GraphQL errors like a champ with unions and ...
Error handling can be frustrating in GraphQL. This post shows you how to use unions and interfaces to handle errors in a more...
Read more >
What does the error message "fork failed: Resource ...
The system ran out of memory and new processes were unable to start because they could not allocate memory. There is not an...
Read more >
Handling MQInput node errors - IBM
If an error occurs in a transactional message flow, and a Failure terminal is not connected: The message is rolled back to the...
Read more >
Get Started with Custom Error Handling in Spring Boot (Java)
Not only do they allow you to centralize exception-handling logic into ... the error and might even implement custom logic, such as logging....
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