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 Merged-In: I06e528cb5e1cd328f82f9561553f3c4b5b0bed26
This commit is contained in:
@@ -212,19 +212,19 @@ public class SliceData {
|
||||
|
||||
public SliceData build() {
|
||||
if (TextUtils.isEmpty(mKey)) {
|
||||
throw new IllegalStateException("Key cannot be empty");
|
||||
throw new InvalidSliceDataException("Key cannot be empty");
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(mTitle)) {
|
||||
throw new IllegalStateException("Title cannot be empty");
|
||||
throw new InvalidSliceDataException("Title cannot be empty");
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(mFragmentClassName)) {
|
||||
throw new IllegalStateException("Fragment Name cannot be empty");
|
||||
throw new InvalidSliceDataException("Fragment Name cannot be empty");
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(mPrefControllerClassName)) {
|
||||
throw new IllegalStateException("Preference Controller cannot be empty");
|
||||
throw new InvalidSliceDataException("Preference Controller cannot be empty");
|
||||
}
|
||||
|
||||
return new SliceData(this);
|
||||
@@ -234,4 +234,11 @@ public class SliceData {
|
||||
return mKey;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvalidSliceDataException extends RuntimeException {
|
||||
|
||||
public InvalidSliceDataException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user