diff options
Diffstat (limited to 'common/src/com/android/io')
-rw-r--r-- | common/src/com/android/io/FileWrapper.java | 8 | ||||
-rw-r--r-- | common/src/com/android/io/StreamException.java | 24 |
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; } } |