Catch exception when failing to create slice

- Created a non-generic exception type when failing SliceData.build()
- Catch exception and log error instead of crash.
- Added a presubmit test

Fixes: 78347031
Test: robotests, atest
Change-Id: I06e528cb5e1cd328f82f9561553f3c4b5b0bed26
This commit is contained in:
Fan Zhang
2018-04-20 12:53:25 -07:00
parent e0069d332d
commit 2a7fcc4d6f
4 changed files with 147 additions and 13 deletions

View File

@@ -67,7 +67,7 @@ public class SliceDataTest {
assertThat(data.isPlatformDefined()).isEqualTo(IS_PLATFORM_DEFINED);
}
@Test(expected = IllegalStateException.class)
@Test(expected = SliceData.InvalidSliceDataException.class)
public void testBuilder_noKey_throwsIllegalStateException() {
new SliceData.Builder()
.setTitle(TITLE)
@@ -80,7 +80,7 @@ public class SliceDataTest {
.build();
}
@Test(expected = IllegalStateException.class)
@Test(expected = SliceData.InvalidSliceDataException.class)
public void testBuilder_noTitle_throwsIllegalStateException() {
new SliceData.Builder()
.setKey(KEY)
@@ -93,7 +93,7 @@ public class SliceDataTest {
.build();
}
@Test(expected = IllegalStateException.class)
@Test(expected = SliceData.InvalidSliceDataException.class)
public void testBuilder_noFragment_throwsIllegalStateException() {
new SliceData.Builder()
.setKey(KEY)
@@ -106,7 +106,7 @@ public class SliceDataTest {
.build();
}
@Test(expected = IllegalStateException.class)
@Test(expected = SliceData.InvalidSliceDataException.class)
public void testBuilder_noPrefController_throwsIllegalStateException() {
new SliceData.Builder()
.setKey(KEY)