yourServiceWrapper.getService().yourMethod(yourParam).enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
if (response.isSuccessful()) {
// success handling
} else if (response.code() == 422) {
// handle 422 error
} else {
// other error handling
}
}
@Override
public void onFailure(Call call, Throwable t) {
// failure handling
}
});
在上述回调函数中,当获取到422状态码时,可以自定义相应的处理方式来解决该问题。