aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/com/android/io
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-03-27 16:27:30 -0700
committerXavier Ducrohet <xav@android.com>2012-03-27 16:33:54 -0700
commit8ea3fa036be099116be43272447b3570e818fa21 (patch)
treed83b17995618eb94d19dcd8c9b273bde1e6b36a4 /common/src/com/android/io
parent9b20bc00147114cba4746ce63bee529f5ca6c69e (diff)
downloadsdk-8ea3fa036be099116be43272447b3570e818fa21.zip
sdk-8ea3fa036be099116be43272447b3570e818fa21.tar.gz
sdk-8ea3fa036be099116be43272447b3570e818fa21.tar.bz2
Ensure that exception during build put a marker on something.
Failure to read the manifest (sometimes due to out of sync resources) could fail to put a marker on the file or project, making the build fail with no feedback. Change-Id: Ib75e0b72e202e14de556ba30f23a6879e3dfc2c8
Diffstat (limited to 'common/src/com/android/io')
-rw-r--r--common/src/com/android/io/FileWrapper.java8
-rw-r--r--common/src/com/android/io/StreamException.java24
2 files changed, 27 insertions, 5 deletions
diff --git a/common/src/com/android/io/FileWrapper.java b/common/src/com/android/io/FileWrapper.java
index 84a1f3e..8be7859 100644
--- a/common/src/com/android/io/FileWrapper.java
+++ b/common/src/com/android/io/FileWrapper.java
@@ -90,7 +90,7 @@ public class FileWrapper extends File implements IAbstractFile {
try {
return new FileInputStream(this);
} catch (FileNotFoundException e) {
- throw new StreamException(e);
+ throw new StreamException(e, this, StreamException.Error.FILENOTFOUND);
}
}
@@ -106,13 +106,13 @@ public class FileWrapper extends File implements IAbstractFile {
fos.write(buffer, 0, count);
}
} catch (IOException e) {
- throw new StreamException(e);
+ throw new StreamException(e, this);
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
- throw new StreamException(e);
+ throw new StreamException(e, this);
}
}
}
@@ -123,7 +123,7 @@ public class FileWrapper extends File implements IAbstractFile {
try {
return new FileOutputStream(this);
} catch (FileNotFoundException e) {
- throw new StreamException(e);
+ throw new StreamException(e, this);
}
}
diff --git a/common/src/com/android/io/StreamException.java b/common/src/com/android/io/StreamException.java
index f67c7a8..9f632f4 100644
--- a/common/src/com/android/io/StreamException.java
+++ b/common/src/com/android/io/StreamException.java
@@ -16,13 +16,35 @@
package com.android.io;
+
/**
* Exception thrown when {@link IAbstractFile#getContents()} fails.
*/
public class StreamException extends Exception {
private static final long serialVersionUID = 1L;
- public StreamException(Exception e) {
+ public static enum Error {
+ DEFAULT, OUTOFSYNC, FILENOTFOUND;
+ }
+
+ private final Error mError;
+ private final IAbstractFile mFile;
+
+ public StreamException(Exception e, IAbstractFile file) {
+ this(e, file, Error.DEFAULT);
+ }
+
+ public StreamException(Exception e, IAbstractFile file, Error error) {
super(e);
+ mFile = file;
+ mError = error;
+ }
+
+ public Error getError() {
+ return mError;
+ }
+
+ public IAbstractFile getFile() {
+ return mFile;
}
}