Ejemplo n.º 1
0
 @Override
 public void onResponse(int responseCode, byte[] body) {
   String exceptionMessage = OpenFeintInternal.getRString(R.string.of_unknown_server_error);
   if (200 <= responseCode && responseCode < 300 && body != null) {
     onSuccess(body);
     return;
   } else if (404 == responseCode) {
     exceptionMessage = OpenFeintInternal.getRString(R.string.of_file_not_found);
   } else
     try {
       // try to parse response body
       JsonFactory jsonFactory = new JsonFactory(); // for thread safety, we make our own.
       JsonParser jp = jsonFactory.createJsonParser(body);
       JsonResourceParser jrp = new JsonResourceParser(jp);
       Object responseBody = jrp.parse();
       if (responseBody != null && responseBody instanceof ServerException) {
         ServerException e = (ServerException) responseBody;
         exceptionMessage = e.exceptionClass + ": " + e.message;
       }
     } catch (IOException e) {
       exceptionMessage = OpenFeintInternal.getRString(R.string.of_error_parsing_error_message);
     }
   onFailure(exceptionMessage);
 }
Ejemplo n.º 2
0
 public void onFailure(String exceptionMessage) {
   OpenFeintInternal.log("ServerException", exceptionMessage);
 }