am 2d83400e: Merge "LayoutLib: Improve error reporting." into honeycomb

* commit '2d83400e59f939a25c471d87dbdc7a50ce7f2a44':
  LayoutLib: Improve error reporting.
This commit is contained in:
Xavier Ducrohet
2011-01-11 13:33:05 -08:00
committed by Android Git Automerger
9 changed files with 35 additions and 47 deletions

View File

@@ -351,7 +351,8 @@ public class BitmapFactory {
If the exception happened on open, bm will be null.
If it happened on close, bm is still valid.
*/
Bridge.getLog().error(null, e);
Bridge.getLog().error(null,
String.format("Error decoding bitmap of id 0x%x", id), e);
} finally {
try {
if (is != null) is.close();

View File

@@ -73,7 +73,7 @@ public final class NinePatch_Delegate {
oos = new ObjectOutputStream(baos);
oos.writeObject(chunk);
} catch (IOException e) {
Bridge.getLog().error("Failed to serialize NinePatchChunk.", e);
Bridge.getLog().error(null, "Failed to serialize NinePatchChunk.", e);
return null;
} finally {
if (oos != null) {
@@ -196,10 +196,10 @@ public final class NinePatch_Delegate {
sChunkCache.put(array, new SoftReference<NinePatchChunk>(chunk));
}
} catch (IOException e) {
Bridge.getLog().error("Failed to deserialize NinePatchChunk content.", e);
Bridge.getLog().error(null, "Failed to deserialize NinePatchChunk content.", e);
return null;
} catch (ClassNotFoundException e) {
Bridge.getLog().error("Failed to deserialize NinePatchChunk class.", e);
Bridge.getLog().error(null, "Failed to deserialize NinePatchChunk class.", e);
return null;
} finally {
if (ois != null) {

View File

@@ -35,7 +35,6 @@ public class XmlUtils_Delegate {
// The Dalvik libraries are able to handle Integer.parse("XXXXXXXX", 16) where XXXXXXX
// is > 80000000 but the Java VM cannot.
int value;
int sign = 1;
int index = 0;
int len = nm.length();
@@ -51,7 +50,7 @@ public class XmlUtils_Delegate {
if (index == (len - 1))
return 0;
char c = nm.charAt(index + 1);
char c = nm.charAt(index + 1);
if ('x' == c || 'X' == c) {
index += 2;
@@ -61,14 +60,11 @@ public class XmlUtils_Delegate {
base = 8;
}
}
else if ('#' == nm.charAt(index))
{
else if ('#' == nm.charAt(index)) {
index++;
base = 16;
return ((int)Long.parseLong(nm.substring(index), base)) * sign;
}
return Integer.parseInt(nm.substring(index), base) * sign;
return ((int)Long.parseLong(nm.substring(index), base)) * sign;
}
}

View File

@@ -141,16 +141,6 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
System.err.println(message);
}
@Override
public void error(String tag, Throwable t) {
String message = t.getMessage();
if (message == null) {
message = t.getClass().getName();
}
System.err.println(message);
}
@Override
public void error(String tag, String message, Throwable throwable) {
System.err.println(message);

View File

@@ -178,8 +178,10 @@ public final class BridgeInflater extends LayoutInflater {
return inflate(bridgeParser, root);
} catch (Exception e) {
Bridge.getLog().error(null, e);
// return null below.
Bridge.getLog().error(null,
"Failed to parse file " + f.getAbsolutePath(), e);
return null;
}
}
}

View File

@@ -43,7 +43,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
/**
@@ -173,14 +172,13 @@ public final class BridgeResources extends Resources {
return ColorStateList.createFromXml(this,
new BridgeXmlBlockParser(parser, mContext, resValue.isFramework()));
} catch (XmlPullParserException e) {
Bridge.getLog().error(null, e);
} catch (FileNotFoundException e) {
// will not happen, since we pre-check
} catch (IOException e) {
Bridge.getLog().error(null, e);
}
} catch (Exception e) {
// this is an error and not warning since the file existence is checked before
// attempting to parse it.
Bridge.getLog().error(null, "Failed to parse file " + value, e);
return null;
}
} else {
// try to load the color state list from an int
try {
@@ -245,7 +243,8 @@ public final class BridgeResources extends Resources {
return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]);
}
} catch (XmlPullParserException e) {
Bridge.getLog().error(null, e);
Bridge.getLog().error(null,
"Failed to configure parser for " + value.getValue(), e);
// we'll return null below.
} catch (FileNotFoundException e) {
// this shouldn't happen since we check above.
@@ -279,7 +278,8 @@ public final class BridgeResources extends Resources {
return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]);
}
} catch (XmlPullParserException e) {
Bridge.getLog().error(null, e);
Bridge.getLog().error(null,
"Failed to configure parser for " + value.getValue(), e);
// we'll return null below.
} catch (FileNotFoundException e) {
// this shouldn't happen since we check above.

View File

@@ -322,9 +322,9 @@ public final class BridgeTypedArray extends TypedArray {
} catch (Exception e) {
// this is an error and not warning since the file existence is checked before
// attempting to parse it.
Bridge.getLog().error(null, e);
Bridge.getLog().error(null, "Failed to parse file " + value, e);
// return null below.
return null;
}
// looks like were unable to resolve the color value.

View File

@@ -365,7 +365,7 @@ public class RenderSessionImpl {
}
// log it
mParams.getLog().error("Scene inflate failed", t);
mParams.getLog().error(null, "Scene inflate failed", t);
return ERROR_INFLATION.createResult(t.getMessage(), t);
}
@@ -481,7 +481,7 @@ public class RenderSessionImpl {
}
// log it
mParams.getLog().error("Scene Render failed", t);
mParams.getLog().error(null, "Scene Render failed", t);
return ERROR_UNKNOWN.createResult(t.getMessage(), t);
}

View File

@@ -27,7 +27,6 @@ import com.android.ninepatch.NinePatchChunk;
import org.kxml2.io.KXmlParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import android.graphics.Bitmap;
import android.graphics.Bitmap_Delegate;
@@ -40,7 +39,6 @@ import android.graphics.drawable.NinePatchDrawable;
import android.util.TypedValue;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -162,7 +160,7 @@ public final class ResourceHelper {
// URL is wrong, we'll return null below
} catch (IOException e) {
// failed to read the file, we'll return null below.
Bridge.getLog().error(null, e);
Bridge.getLog().error(null, "Failed lot load " + file.getAbsolutePath(), e);
}
}
@@ -190,13 +188,14 @@ public final class ResourceHelper {
d = Drawable.createFromXml(context.getResources(),
new BridgeXmlBlockParser(parser, context, isFramework));
return d;
} catch (XmlPullParserException e) {
Bridge.getLog().error(null, e);
} catch (FileNotFoundException e) {
// will not happen, since we pre-check
} catch (IOException e) {
Bridge.getLog().error(null, e);
} catch (Exception e) {
// this is an error and not warning since the file existence is checked before
// attempting to parse it.
Bridge.getLog().error(null, "Failed to parse file " + value, e);
}
} else {
Bridge.getLog().error(null,
String.format("File %s does not exist (or is not a file)", stringValue));
}
return null;
@@ -222,7 +221,7 @@ public final class ResourceHelper {
return new BitmapDrawable(context.getResources(), bitmap);
} catch (IOException e) {
// we'll return null below
Bridge.getLog().error(null, e);
Bridge.getLog().error(null, "Failed lot load " + bmpFile.getAbsolutePath(), e);
}
} else {
// attempt to get a color from the value