Routing-controllers: Why the stack trace and why the log output on 404?

Created on 19 Sep 2017  路  5Comments  路  Source: typestack/routing-controllers

When throwing an NotFoundError as described in the documentation I would expect that my user would get the following back:

404 with the body:

{
    "name": "NotFoundError",
    "message": "My error text"
}

At least this is how I read the documentation. But I also get an attribute "stack" in this message. Provideing my users with A) information I don't want to share, B) useless information (from their perspective). How do I get rid of this unwanted/undocumented attribute?

I also see a stack trace in the servers log. Telling me that a NotFoundError occurred. How do I remove that?

Thank you for your help.

Kind regards Morten

question

All 5 comments

if (error.stack && this.developmentMode)
    processedError.stack = error.stack;

This is default handler code. So change your NODE_ENV to production or provide developmentMode option in routing-controllers config.

Cool thank you. Actually upgrading from 0.7.0 to 0.7.2 fixed my issues. I have another one now though. I get html content back on a 404 instead of json. Do you have quick fix for that as well? Note: all my controllers are already annotated with "@JsonController".

It was fixed in #277, waiting for new release on npm 馃槥

I added a test case to be sure - 17a53c6 馃槈

This will be released today in 0.7.3

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

impzero picture impzero  路  4Comments

kkorus picture kkorus  路  4Comments

codedoge picture codedoge  路  6Comments

OysteinAmundsen picture OysteinAmundsen  路  3Comments

posabsolute picture posabsolute  路  4Comments