diff --git a/app/core/src/main/java/com/fsck/k9/search/ConditionsTreeNode.java b/app/core/src/main/java/com/fsck/k9/search/ConditionsTreeNode.java index 83b6fe11f..e915f5363 100644 --- a/app/core/src/main/java/com/fsck/k9/search/ConditionsTreeNode.java +++ b/app/core/src/main/java/com/fsck/k9/search/ConditionsTreeNode.java @@ -164,9 +164,8 @@ public class ConditionsTreeNode implements Parcelable { * * @param expr Expression to 'AND' with. * @return New top AND node. - * @throws Exception */ - public ConditionsTreeNode and(ConditionsTreeNode expr) throws Exception { + public ConditionsTreeNode and(ConditionsTreeNode expr) { return add(expr, Operator.AND); } @@ -179,13 +178,8 @@ public class ConditionsTreeNode implements Parcelable { * @return New top AND node, new root. */ public ConditionsTreeNode and(SearchCondition condition) { - try { - ConditionsTreeNode tmp = new ConditionsTreeNode(condition); - return and(tmp); - } catch (Exception e) { - // impossible - return null; - } + ConditionsTreeNode tmp = new ConditionsTreeNode(condition); + return and(tmp); } /** @@ -194,9 +188,8 @@ public class ConditionsTreeNode implements Parcelable { * * @param expr Expression to 'OR' with. * @return New top OR node. - * @throws Exception */ - public ConditionsTreeNode or(ConditionsTreeNode expr) throws Exception { + public ConditionsTreeNode or(ConditionsTreeNode expr) { return add(expr, Operator.OR); } @@ -209,13 +202,8 @@ public class ConditionsTreeNode implements Parcelable { * @return New top OR node, new root. */ public ConditionsTreeNode or(SearchCondition condition) { - try { - ConditionsTreeNode tmp = new ConditionsTreeNode(condition); - return or(tmp); - } catch (Exception e) { - // impossible - return null; - } + ConditionsTreeNode tmp = new ConditionsTreeNode(condition); + return or(tmp); } /** @@ -295,11 +283,11 @@ public class ConditionsTreeNode implements Parcelable { * @param node Node to add. * @param op Operator that will connect the new node with this one. * @return New parent node, containing the operator. - * @throws Exception Throws when the provided new node does not have a null parent. + * @throws IllegalArgumentException Throws when the provided new node does not have a null parent. */ - private ConditionsTreeNode add(ConditionsTreeNode node, Operator op) throws Exception { + private ConditionsTreeNode add(ConditionsTreeNode node, Operator op) { if (node.mParent != null) { - throw new Exception("Can only add new expressions from root node down."); + throw new IllegalArgumentException("Can only add new expressions from root node down."); } ConditionsTreeNode tmpNode = new ConditionsTreeNode(mParent, op); diff --git a/app/core/src/main/java/com/fsck/k9/search/LocalSearch.java b/app/core/src/main/java/com/fsck/k9/search/LocalSearch.java index bf0f24995..d46c8fcb4 100644 --- a/app/core/src/main/java/com/fsck/k9/search/LocalSearch.java +++ b/app/core/src/main/java/com/fsck/k9/search/LocalSearch.java @@ -170,13 +170,8 @@ public class LocalSearch implements SearchSpecification { * @return New top AND node, new root. */ public ConditionsTreeNode and(SearchCondition condition) { - try { - ConditionsTreeNode tmp = new ConditionsTreeNode(condition); - return and(tmp); - } catch (Exception e) { - // impossible - return null; - } + ConditionsTreeNode tmp = new ConditionsTreeNode(condition); + return and(tmp); } /** @@ -185,9 +180,8 @@ public class LocalSearch implements SearchSpecification { * * @param node Node to 'AND' with. * @return New top AND node, new root. - * @throws Exception */ - public ConditionsTreeNode and(ConditionsTreeNode node) throws Exception { + public ConditionsTreeNode and(ConditionsTreeNode node) { mLeafSet.addAll(node.getLeafSet()); if (mConditions == null) { @@ -207,13 +201,8 @@ public class LocalSearch implements SearchSpecification { * @return New top OR node, new root. */ public ConditionsTreeNode or(SearchCondition condition) { - try { - ConditionsTreeNode tmp = new ConditionsTreeNode(condition); - return or(tmp); - } catch (Exception e) { - // impossible - return null; - } + ConditionsTreeNode tmp = new ConditionsTreeNode(condition); + return or(tmp); } /** @@ -222,9 +211,8 @@ public class LocalSearch implements SearchSpecification { * * @param node Node to 'OR' with. * @return New top OR node, new root. - * @throws Exception */ - public ConditionsTreeNode or(ConditionsTreeNode node) throws Exception { + public ConditionsTreeNode or(ConditionsTreeNode node) { mLeafSet.addAll(node.getLeafSet()); if (mConditions == null) {