Retrofit 2: responseBodyConverter converts to null object

前端 未结 1 1013
误落风尘
误落风尘 2021-01-04 19:46

I\'m using the latest (as of now 2.0.0-beta4) version of Retrofit. When receiving 200 OK code from server, everything is working fine. But I want to deal with not OK respons

1条回答
  •  执笔经年
    2021-01-04 20:05

    Found the answer in futurestud.io blog comments:

    Changed the APIError.java to this:

    public class APIError {
    
        Error error;
    
        public Error getError() {
            return error;
        }
    
        public static class Error {
    
            String name;
            int status;
            String message;
            int statusCode;
            String code;
            String stack;
    
            public String getName() {
                return name;
            }
    
            public int getStatus() {
                return status;
            }
    
            public String getCode() {
                return code;
            }
    
        }
    }
    

    0 讨论(0)
提交回复
热议问题