Skip to content

question: How do I customize internal HttpErrors with custom Http errors with KoaDriver? #650

@coneforapine

Description

@coneforapine

I was sending custom HttpErrors that changes the response to the user but I can't do this when I'm validating request bodies because it's using the one that came with the library.

This is the response I want to throw when a validation fails;

{
    "status": false,
    "message": "Validation errors.",
    "errors": "ValidationError[] from class validator"
}

This is what it currently returns

{
    "name": "BadRequestError",
    "message": "Invalid body, check 'errors' property for more info.",
     "errors": "ValidationError[] from class validator"
}

One way that I could find is to use this but since I'm using Koa I can't use it.

One workaround for this is disabling the validator from @Body() and calling class-validator inside the request function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionQuestions about the usage of the library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions