New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve hooks error reporting #289

Closed
fra967 opened this Issue May 30, 2017 · 6 comments

Comments

Projects
3 participants
@fra967
Copy link
Member

fra967 commented May 30, 2017

Currently (API 1.16.6 and API 2.0 rc1) when a hook fails the error message is logged, for example

Hook Error',\n details: 'The hook \\'xxxx\\' failed: \\'TypeError: Cannot read property \\'toString\\' of undefined\\''

However no additional information is available in order to troubleshoot the error, not even a line number of where the error has been raised

The only option is to add a manual console.log to trap the whole error in
https://github.com/dadi/api/blob/master/dadi/lib/model/hook.js#L38

Please add the first line of the error details (which should include the offending file and line number) in the error message

@jimlambie jimlambie added this to Backlog in API Version 2 May 31, 2017

@jimlambie jimlambie moved this from Backlog to In Progress in API Version 2 May 31, 2017

@jimlambie jimlambie modified the milestone: 2.0.0 May 31, 2017

@jimlambie jimlambie moved this from In Progress to Review in API Version 2 Jun 3, 2017

@jimlambie jimlambie referenced this issue Jun 3, 2017

Merged

Version 2.0.0 #297

@jimlambie

This comment has been minimized.

Copy link
Member

jimlambie commented Jun 3, 2017

@eduardoboucas
d103f62 and API v2.0.0 introduces the addition of the first line of the stack trace. Closing this issue, we can raise a new one when it comes time to include greater detail in the API errors across the board.

@jimlambie jimlambie closed this Jun 3, 2017

@fra967

This comment has been minimized.

Copy link
Member Author

fra967 commented Jul 3, 2017

is it just me or this has been removed in api 2.1.2?

@eduardoboucas

This comment has been minimized.

Copy link
Member

eduardoboucas commented Jul 3, 2017

@fra967 Not intentionally. We did add the ability for hooks to throw custom errors, which I suspect might be causing the issue you're seeing.

Could you share the output of the error you're seeing?

@eduardoboucas eduardoboucas reopened this Jul 3, 2017

@fra967

This comment has been minimized.

Copy link
Member Author

fra967 commented Jul 3, 2017

Sample response (API 2.1.2)

{
    "success": false,
    "errors": [
        {
            "code": "API-0002",
            "title": "Hook Error",
            "details": "The hook 'slugify' failed: 'undefined'",
            "docLink": "http://docs.dadi.tech/errors/api/API-0002"
        }
    ]
}
@eduardoboucas

This comment has been minimized.

Copy link
Member

eduardoboucas commented Jul 4, 2017

Do you have any information you can share about the nature of the error being thrown? I wasn't able to replicate this behaviour.

I added a simple runtime error to a hook (calling a function that doesn't exist), and I get this:

{
    "success": false,
    "errors": [
        {
            "code": "API-0002",
            "title": "Hook Error",
            "details": "The hook 'slugify' failed: 'functionThatDoesNotExist is not defined\n    at Hook.module.exports (/Users/eduardoboucas/Sites/publish-api/workspace/hooks/slugify.js:20:3)'",
            "docLink": "http://docs.dadi.tech/errors/api/API-0002"
        }
    ]
}
@jimlambie

This comment has been minimized.

Copy link
Member

jimlambie commented Jul 5, 2017

Closed by a5cb253

@jimlambie jimlambie closed this Jul 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment