summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2015-03-09 15:32:50 -0700
committerAlan Viverette <alanv@google.com>2015-03-09 15:32:50 -0700
commit93795053da04b0f16dadb6e56f6056bd2dd37875 (patch)
treec85d11c6381c102cbc6bbe76f1b7754f5d0d2136 /core
parent3c36b8e9569292b7da9a916b148a21dd6c273dc9 (diff)
downloadframeworks_base-93795053da04b0f16dadb6e56f6056bd2dd37875.zip
frameworks_base-93795053da04b0f16dadb6e56f6056bd2dd37875.tar.gz
frameworks_base-93795053da04b0f16dadb6e56f6056bd2dd37875.tar.bz2
Make TypedArray and LayoutInflater exceptions more useful
Include unresolved TypedValue data in TypedArray exceptions, wrap all LayoutInflater exceptions with the parser position. Bug: 19658760 Change-Id: I8965bdc4d0c58c082cb7129c3b692a3e5418cfdb
Diffstat (limited to 'core')
-rw-r--r--core/java/android/content/res/TypedArray.java32
-rw-r--r--core/java/android/view/LayoutInflater.java4
2 files changed, 25 insertions, 11 deletions
diff --git a/core/java/android/content/res/TypedArray.java b/core/java/android/content/res/TypedArray.java
index 410849a..1fca920 100644
--- a/core/java/android/content/res/TypedArray.java
+++ b/core/java/android/content/res/TypedArray.java
@@ -444,8 +444,10 @@ public class TypedArray {
}
return defValue;
} else if (type == TypedValue.TYPE_ATTRIBUTE) {
+ final TypedValue value = mValue;
+ getValueAt(index*AssetManager.STYLE_NUM_ENTRIES, value);
throw new UnsupportedOperationException(
- "Failed to resolve attribute at index " + index);
+ "Failed to resolve attribute at index " + index + ": " + value);
}
throw new UnsupportedOperationException("Can't convert to color: type=0x"
@@ -480,7 +482,7 @@ public class TypedArray {
if (getValueAt(index*AssetManager.STYLE_NUM_ENTRIES, value)) {
if (value.type == TypedValue.TYPE_ATTRIBUTE) {
throw new UnsupportedOperationException(
- "Failed to resolve attribute at index " + index);
+ "Failed to resolve attribute at index " + index + ": " + value);
}
return mResources.loadColorStateList(value, value.resourceId, mTheme);
}
@@ -516,8 +518,10 @@ public class TypedArray {
&& type <= TypedValue.TYPE_LAST_INT) {
return data[index+AssetManager.STYLE_DATA];
} else if (type == TypedValue.TYPE_ATTRIBUTE) {
+ final TypedValue value = mValue;
+ getValueAt(index*AssetManager.STYLE_NUM_ENTRIES, value);
throw new UnsupportedOperationException(
- "Failed to resolve attribute at index " + index);
+ "Failed to resolve attribute at index " + index + ": " + value);
}
throw new UnsupportedOperationException("Can't convert to integer: type=0x"
@@ -560,8 +564,10 @@ public class TypedArray {
return TypedValue.complexToDimension(
data[index + AssetManager.STYLE_DATA], mMetrics);
} else if (type == TypedValue.TYPE_ATTRIBUTE) {
+ final TypedValue value = mValue;
+ getValueAt(index*AssetManager.STYLE_NUM_ENTRIES, value);
throw new UnsupportedOperationException(
- "Failed to resolve attribute at index " + index);
+ "Failed to resolve attribute at index " + index + ": " + value);
}
throw new UnsupportedOperationException("Can't convert to dimension: type=0x"
@@ -605,8 +611,10 @@ public class TypedArray {
return TypedValue.complexToDimensionPixelOffset(
data[index + AssetManager.STYLE_DATA], mMetrics);
} else if (type == TypedValue.TYPE_ATTRIBUTE) {
+ final TypedValue value = mValue;
+ getValueAt(index*AssetManager.STYLE_NUM_ENTRIES, value);
throw new UnsupportedOperationException(
- "Failed to resolve attribute at index " + index);
+ "Failed to resolve attribute at index " + index + ": " + value);
}
throw new UnsupportedOperationException("Can't convert to dimension: type=0x"
@@ -651,8 +659,10 @@ public class TypedArray {
return TypedValue.complexToDimensionPixelSize(
data[index+AssetManager.STYLE_DATA], mMetrics);
} else if (type == TypedValue.TYPE_ATTRIBUTE) {
+ final TypedValue value = mValue;
+ getValueAt(index*AssetManager.STYLE_NUM_ENTRIES, value);
throw new UnsupportedOperationException(
- "Failed to resolve attribute at index " + index);
+ "Failed to resolve attribute at index " + index + ": " + value);
}
throw new UnsupportedOperationException("Can't convert to dimension: type=0x"
@@ -692,8 +702,10 @@ public class TypedArray {
return TypedValue.complexToDimensionPixelSize(
data[index+AssetManager.STYLE_DATA], mMetrics);
} else if (type == TypedValue.TYPE_ATTRIBUTE) {
+ final TypedValue value = mValue;
+ getValueAt(index*AssetManager.STYLE_NUM_ENTRIES, value);
throw new UnsupportedOperationException(
- "Failed to resolve attribute at index " + index);
+ "Failed to resolve attribute at index " + index + ": " + value);
}
throw new UnsupportedOperationException(getPositionDescription()
@@ -765,8 +777,10 @@ public class TypedArray {
return TypedValue.complexToFraction(
data[index+AssetManager.STYLE_DATA], base, pbase);
} else if (type == TypedValue.TYPE_ATTRIBUTE) {
+ final TypedValue value = mValue;
+ getValueAt(index*AssetManager.STYLE_NUM_ENTRIES, value);
throw new UnsupportedOperationException(
- "Failed to resolve attribute at index " + index);
+ "Failed to resolve attribute at index " + index + ": " + value);
}
throw new UnsupportedOperationException("Can't convert to fraction: type=0x"
@@ -853,7 +867,7 @@ public class TypedArray {
if (getValueAt(index*AssetManager.STYLE_NUM_ENTRIES, value)) {
if (value.type == TypedValue.TYPE_ATTRIBUTE) {
throw new UnsupportedOperationException(
- "Failed to resolve attribute at index " + index);
+ "Failed to resolve attribute at index " + index + ": " + value);
}
return mResources.loadDrawable(value, value.resourceId, mTheme);
}
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java
index 1014573..1a07aee 100644
--- a/core/java/android/view/LayoutInflater.java
+++ b/core/java/android/view/LayoutInflater.java
@@ -532,10 +532,10 @@ public abstract class LayoutInflater {
InflateException ex = new InflateException(e.getMessage());
ex.initCause(e);
throw ex;
- } catch (IOException e) {
+ } catch (Exception e) {
InflateException ex = new InflateException(
parser.getPositionDescription()
- + ": " + e.getMessage());
+ + ": " + e.getMessage());
ex.initCause(e);
throw ex;
} finally {