aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Chabot <brettchabot@android.com>2011-06-23 14:45:51 -0700
committerBrett Chabot <brettchabot@android.com>2011-06-23 14:49:24 -0700
commitebce90426a4bbb29a2829d138638d4f8e877f1f1 (patch)
tree85506a74748b94df9d011b543390e8a738a1b9e8
parent5773adb742c8915f9f72b47ab8f00ed4f79357ae (diff)
downloadsdk-ebce90426a4bbb29a2829d138638d4f8e877f1f1.zip
sdk-ebce90426a4bbb29a2829d138638d4f8e877f1f1.tar.gz
sdk-ebce90426a4bbb29a2829d138638d4f8e877f1f1.tar.bz2
pullFile exception handling.
Make SyncService.pullFile throw SyncException instead of IOException if it cannot write to local file. Bug 4600585 Change-Id: Ic3ab9fd7d1a05280ee14a310b9c8053371bb4e37
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/SyncException.java2
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/SyncService.java8
2 files changed, 9 insertions, 1 deletions
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/SyncException.java b/ddms/libs/ddmlib/src/com/android/ddmlib/SyncException.java
index 5f84f64..76de367 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/SyncException.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/SyncException.java
@@ -44,6 +44,8 @@ public class SyncException extends CanceledException {
REMOTE_PATH_LENGTH("Remote path is too long."),
/** error while reading local file. */
FILE_READ_ERROR("Reading local file failed!"),
+ /** error while writing local file. */
+ FILE_WRITE_ERROR("Writing local file failed!"),
/** attempting to push a directory. */
LOCAL_IS_DIRECTORY("Local path is a directory."),
/** attempting to push a non-existent file. */
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/SyncService.java b/ddms/libs/ddmlib/src/com/android/ddmlib/SyncService.java
index 03a68aa..6a94d22 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/SyncService.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/SyncService.java
@@ -516,7 +516,13 @@ public final class SyncService {
// create the stream to write in the file. We use a new try/catch block to differentiate
// between file and network io exceptions.
FileOutputStream fos = null;
- fos = new FileOutputStream(f);
+ try {
+ fos = new FileOutputStream(f);
+ } catch (IOException e) {
+ Log.e("ddms", String.format("Failed to open local file %s for writing, Reason: %s",
+ f.getAbsolutePath(), e.toString()));
+ throw new SyncException(SyncError.FILE_WRITE_ERROR);
+ }
// the buffer to read the data
byte[] data = new byte[SYNC_DATA_MAX];