<string name="clipboard_text_copied">Copied to clipboard</string>
<string name="error_cant_bind_to_operations_service">Critical error: can not perform operations</string>
+
+ <string name="network_error_socket_exception">An error occurred while connecting with the server.</string>
+ <string name="network_error_socket_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
+ <string name="network_error_connect_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
+ <string name="unexpected_exception">Unexpected exception</string>
+
+
</resources>
package com.owncloud.android.utils;
import java.io.File;
-
+import java.net.SocketTimeoutException;
+import org.apache.commons.httpclient.ConnectTimeoutException;
import android.content.res.Resources;
import com.owncloud.android.R;
}
}
+
+ 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;
}
}