Cleaned up the new exceptions and made them a little cleaner.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/a0a837aa Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/a0a837aa Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/a0a837aa Branch: refs/heads/vxquery_0_3_staging Commit: a0a837aab741a95ec1507c5ab4209a401f72fc4c Parents: 98f9597 Author: Preston Carman <[email protected]> Authored: Mon Apr 7 20:48:18 2014 -0700 Committer: Preston Carman <[email protected]> Committed: Mon Apr 7 20:48:18 2014 -0700 ---------------------------------------------------------------------- .../exceptions/VXQueryDataException.java | 41 ++++++++++++++++++++ .../VXQueryFileNotFoundException.java | 30 ++++++-------- .../exceptions/VXQueryParseException.java | 30 ++++++-------- .../VXQueryCollectionOperatorDescriptor.java | 18 +-------- .../org/apache/vxquery/xmlparser/XMLParser.java | 5 +-- 5 files changed, 69 insertions(+), 55 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/a0a837aa/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryDataException.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryDataException.java b/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryDataException.java new file mode 100644 index 0000000..79a37af --- /dev/null +++ b/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryDataException.java @@ -0,0 +1,41 @@ +/* + * 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.vxquery.exceptions; + +import java.io.File; + +import edu.uci.ics.hyracks.api.exceptions.HyracksDataException; + +public class VXQueryDataException extends HyracksDataException { + + private static final long serialVersionUID = 1L; + + private File file; + + public VXQueryDataException(String message, Exception ex, File file) { + super(message, ex); + this.file = file; + } + + @Override + public String getMessage() { + String message = super.getMessage(); + message = message.replaceAll("\\[nodeId\\]", getNodeId()); + message = message.replaceAll("\\[path\\]", file.getAbsolutePath()); + return message; + } +} http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/a0a837aa/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryFileNotFoundException.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryFileNotFoundException.java b/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryFileNotFoundException.java index 27a0a2e..2856178 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryFileNotFoundException.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryFileNotFoundException.java @@ -1,11 +1,13 @@ /* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * + * 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. @@ -14,22 +16,14 @@ */ package org.apache.vxquery.exceptions; -import edu.uci.ics.hyracks.api.exceptions.HyracksDataException; +import java.io.File; -public class VXQueryFileNotFoundException extends HyracksDataException { +public class VXQueryFileNotFoundException extends VXQueryDataException { private static final long serialVersionUID = 1L; - public VXQueryFileNotFoundException() { - super(); - } - - public VXQueryFileNotFoundException(Exception ex) { - super(ex); - } - - public VXQueryFileNotFoundException(String msg) { - super(msg); + public VXQueryFileNotFoundException(Exception ex, File file) { + super("The file ([nodeId]:[path]) can not be found.", ex, file); } } http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/a0a837aa/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryParseException.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryParseException.java b/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryParseException.java index f1b4155..f0d66fb 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryParseException.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/exceptions/VXQueryParseException.java @@ -1,11 +1,13 @@ /* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * + * 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. @@ -14,22 +16,14 @@ */ package org.apache.vxquery.exceptions; -import edu.uci.ics.hyracks.api.exceptions.HyracksDataException; +import java.io.File; -public class VXQueryParseException extends HyracksDataException { +public class VXQueryParseException extends VXQueryDataException { private static final long serialVersionUID = 1L; - public VXQueryParseException() { - super(); - } - - public VXQueryParseException(Exception ex) { - super(ex); - } - - public VXQueryParseException(String msg) { - super(msg); + public VXQueryParseException(Exception ex, File file) { + super("The file ([nodeId]:[path]) threw a SAXException during parsing.", ex, file); } } http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/a0a837aa/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java index 54007c8..44e6ad6 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java @@ -123,23 +123,9 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO abvsFileNode.reset(); try { parser.parseFile(file, in, abvsFileNode); - } catch (VXQueryFileNotFoundException e) { - String message = "The file (" + nodeId + ":" + file.getAbsolutePath() + ") can not be found."; - HyracksDataException hde = new HyracksDataException(message, e.getCause()); - hde.setNodeId(nodeId); - throw hde; - } catch (VXQueryParseException e) { - String message = "The file (" + nodeId + ":" + file.getAbsolutePath() - + ") throw a SAXException durring parsing."; - HyracksDataException hde = new HyracksDataException(message, e.getCause()); - hde.setNodeId(nodeId); - throw hde; } catch (HyracksDataException e) { - String message = "The file (" + nodeId + ":" + file.getAbsolutePath() - + ") throw the following error during parsing: " + e.getMessage(); - HyracksDataException hde = new HyracksDataException(message, e.getCause()); - hde.setNodeId(nodeId); - throw hde; + e.setNodeId(nodeId); + throw e; } TaggedValuePointable tvp = ppool.takeOne(TaggedValuePointable.class); http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/a0a837aa/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java index 125557b..445915b 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java @@ -46,7 +46,6 @@ public class XMLParser { } } - public void parseFile(File file, InputSource in, ArrayBackedValueStorage abvs) throws HyracksDataException { try { if (file.getName().toLowerCase().endsWith(".xml.gz")) { @@ -57,9 +56,9 @@ public class XMLParser { parser.parse(in); handler.write(abvs); } catch (FileNotFoundException e) { - throw new VXQueryFileNotFoundException(e); + throw new VXQueryFileNotFoundException(e, file); } catch (SAXException e) { - throw new VXQueryParseException(e); + throw new VXQueryParseException(e, file); } catch (IOException e) { throw new HyracksDataException(e); }
