[FIX] Вывод сообщения об ошибке в jsonRequest

This commit is contained in:
Gravit 2019-05-09 19:42:07 +07:00
parent 4ab3c3a9f4
commit bb04ed849c
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -3,6 +3,7 @@
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -61,6 +62,10 @@ public static JsonElement jsonRequest(JsonElement request, URL url) throws IOExc
try { try {
return parser.parse(reader); return parser.parse(reader);
} catch (Exception e) { } catch (Exception e) {
if(200 > statusCode || statusCode > 300) {
LogHelper.error("JsonRequest failed. Server response code %d", statusCode);
throw new IOException(e);
}
return null; return null;
} }
} }