diff options
author | Alan Viverette <alanv@google.com> | 2015-03-09 15:32:50 -0700 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2015-03-09 15:32:50 -0700 |
commit | 93795053da04b0f16dadb6e56f6056bd2dd37875 (patch) | |
tree | c85d11c6381c102cbc6bbe76f1b7754f5d0d2136 /core/java/android/content/res | |
parent | 3c36b8e9569292b7da9a916b148a21dd6c273dc9 (diff) | |
download | frameworks_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/java/android/content/res')
-rw-r--r-- | core/java/android/content/res/TypedArray.java | 32 |
1 files changed, 23 insertions, 9 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); } |