Skip to content
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

Unexpected behavior when Status is created for non-existent status code #169

Closed
ddobrin opened this issue Feb 28, 2018 · 2 comments
Closed
Assignees
Labels
enhancement Issue: Enhancement

Comments

@ddobrin
Copy link
Contributor

ddobrin commented Feb 28, 2018

Framework user reports an incorrect behavior when a Status object is created, and the status and its associated description are not found in the status.yml file

@stevehu
Copy link
Contributor

stevehu commented Apr 20, 2018

There is an exception happens when the framework tries to construct a Status object from status.yml config file. What would be the best approach to handle this scenario?

  • Create another error code to indicate that a specific status code is missing from status.yml?
  • Just log it as an error in the stdout and log file?

@stevehu stevehu self-assigned this May 16, 2018
@stevehu
Copy link
Contributor

stevehu commented May 29, 2018

A default method has been added into MiddlewareHandler interface to setExchangeStatus. If the status code is not loaded successfully from status.yml file, then an ERROR_NOT_DEFINED will be returned.

    default void setExchangeStatus(HttpServerExchange exchange, String code, final Object... args) {
        Status status = new Status(code, args);
        if(status.getStatusCode() == 0) {
            // There is no entry in status.yml for this particular error code.
            status = new Status(ERROR_NOT_DEFINED, code);
        }
        exchange.setStatusCode(status.getStatusCode());
        exchange.getResponseSender().send(status.toString());
        logger.error(status.toString());
    }

@stevehu stevehu added the enhancement Issue: Enhancement label May 29, 2018
younggwon1 pushed a commit to younggwon1/light-4j that referenced this issue Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue: Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants