Skip to content

Error Handler does not work on 404 #87

@TheoSabattie

Description

@TheoSabattie

Hello',

I am trying to return a json message on error.
There is no problem when I use defined route and next.error method.
But when that is not a defined route, the 404 response return an html text. :(

Test :

class Main 
{    
    static function main() 
    {
        var app = new App();
        
        app.router.register(new ErrorMaker());
        app.error(ErrorHandler.handle(JsonMessage));
        
        app.http(8443);
    }
}

class ErrorMaker implements IRoute
{
    @:get("/")
    function index() {
        next.error(new Error("Something wrong happened"));
    }
}

http://myUrl/ => JSON
http://myUrl/something => HTML

I assumed that come from l:373 from AutoRegisterRoute.hx but I don't understand very well the macro part of haxe for the moment.

Does someone will be able to fix that?

There is also an other issue related to the same piece of macro:
#55

Thanks in advance,

Théo Sabattié

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions