Spring RestTemplate invoking webservice with errors and analyze status code

前端 未结 5 921
执笔经年
执笔经年 2020-12-07 17:39

I designed a webservice to perform a task if request parameters are OK, or return 401 Unauthorized HTTP status code if request parameters are wrong or empty.

I\'m us

5条回答
  •  既然无缘
    2020-12-07 18:42

    In my rest service I catch HttpStatusCodeException instead of Exception since HttpStatusCodeException has a method for getting the status code

    catch(HttpStatusCodeException e) {
        log.debug("Status Code", e.getStatusCode());
    }
    

提交回复
热议问题