Merge "Catch exception when failing to create slice" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-04-21 02:03:49 +00:00
committed by Android (Google) Code Review
4 changed files with 147 additions and 13 deletions

View File

@@ -227,19 +227,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);
@@ -249,4 +249,11 @@ public class SliceData {
return mKey;
}
}
public static class InvalidSliceDataException extends RuntimeException {
public InvalidSliceDataException(String message) {
super(message);
}
}
}