|
@@ -19,7 +19,8 @@
|
|
package com.owncloud.android.utils;
|
|
package com.owncloud.android.utils;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
-
|
|
|
|
|
|
+import java.net.SocketTimeoutException;
|
|
|
|
+import org.apache.commons.httpclient.ConnectTimeoutException;
|
|
import android.content.res.Resources;
|
|
import android.content.res.Resources;
|
|
|
|
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.R;
|
|
@@ -75,6 +76,35 @@ public class ErrorMessageAdapter {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ return message;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static String getErrorMessage(RemoteOperationResult result , Resources res) {
|
|
|
|
+
|
|
|
|
+ String message = null;
|
|
|
|
+
|
|
|
|
+ if (!result.isSuccess()) {
|
|
|
|
+
|
|
|
|
+ switch (result.getCode()) {
|
|
|
|
+ case WRONG_CONNECTION:
|
|
|
|
+ message = res.getString(R.string.network_error_socket_exception);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case TIMEOUT:
|
|
|
|
+ if (result.getException() instanceof SocketTimeoutException) {
|
|
|
|
+ message = res.getString(R.string.network_error_socket_timeout_exception);
|
|
|
|
+ } else if(result.getException() instanceof ConnectTimeoutException) {
|
|
|
|
+ message = res.getString(R.string.network_error_connect_timeout_exception);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ message = res.getString(R.string.unexpected_exception);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
return message;
|
|
return message;
|
|
}
|
|
}
|
|
}
|
|
}
|