Repository: incubator-blur Updated Branches: refs/heads/master c08882f31 -> 6092e1172
Starting to deal with exception handling. Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/6092e117 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/6092e117 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/6092e117 Branch: refs/heads/master Commit: 6092e117229f56988b2f7d95df3ac86636566361 Parents: c08882f Author: Aaron McCurry <[email protected]> Authored: Tue Sep 23 10:01:27 2014 -0400 Committer: Aaron McCurry <[email protected]> Committed: Tue Sep 23 10:01:27 2014 -0400 ---------------------------------------------------------------------- .../apache/blur/command/ExceptionCollector.java | 34 +++++++++++++++ .../org/apache/blur/command/ThrowException.java | 44 ++++++++++++++++++++ 2 files changed, 78 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6092e117/blur-core/src/main/java/org/apache/blur/command/ExceptionCollector.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/command/ExceptionCollector.java b/blur-core/src/main/java/org/apache/blur/command/ExceptionCollector.java new file mode 100644 index 0000000..45aea3a --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/command/ExceptionCollector.java @@ -0,0 +1,34 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.blur.command; + +import java.util.ArrayList; +import java.util.List; + +@SuppressWarnings("serial") +public class ExceptionCollector extends Exception { + + private List<Throwable> _throwables = new ArrayList<Throwable>(); + + public void add(Throwable t) { + if (_throwables.size() == 0) { + initCause(t); + } + _throwables.add(t); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6092e117/blur-core/src/test/java/org/apache/blur/command/ThrowException.java ---------------------------------------------------------------------- diff --git a/blur-core/src/test/java/org/apache/blur/command/ThrowException.java b/blur-core/src/test/java/org/apache/blur/command/ThrowException.java new file mode 100644 index 0000000..0eef036 --- /dev/null +++ b/blur-core/src/test/java/org/apache/blur/command/ThrowException.java @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.blur.command; + +import java.io.IOException; + +import org.apache.blur.command.annotation.Argument; +import org.apache.blur.command.annotation.OptionalArguments; +import org.apache.blur.command.annotation.RequiredArguments; + +@SuppressWarnings("serial") +@RequiredArguments({ @Argument(name = "table", value = "The name of the table to execute the wait for N number of seconds command.", type = String.class) }) +@OptionalArguments({ + + @Argument(name = "shard", value = "The shard id to execute the wait for N number of seconds command.", type = String.class), + +}) +public class ThrowException extends Command implements IndexReadCommand<Boolean> { + + @Override + public Boolean execute(IndexContext context) throws IOException, InterruptedException { + throw new RuntimeException("error-test"); + } + + @Override + public String getName() { + return "error"; + } + +}
