Reduce exception wrapping for casting and printing

Change-Id: I1911125b2fa93b743bea8cd16211e3bd464dbf1e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1782
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
index d5b8e74..be6827f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -4878,7 +4878,7 @@
     <test-case FilePath="open-closed">
       <compilation-unit name="query-issue487"><!-- This test case is never run!!!! -->
         <output-dir compare="Text">query-issue487</output-dir>
-        <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+        <expected-error>type mismatch: missing a required closed field name: string</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="open-closed">
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectPointableVisitor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectPointableVisitor.java
index 1a75115..dc8e461 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectPointableVisitor.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectPointableVisitor.java
@@ -45,39 +45,31 @@
     private final Map<IVisitablePointable, IJListAccessor> laccessorToPrinter = new HashMap<IVisitablePointable, IJListAccessor>();
 
     @Override
-    public IJObject visit(AListVisitablePointable accessor, TypeInfo arg) throws AsterixException {
+    public IJObject visit(AListVisitablePointable accessor, TypeInfo arg) throws HyracksDataException {
         IJObject result = null;
         IJListAccessor jListAccessor = laccessorToPrinter.get(accessor);
         if (jListAccessor == null) {
             jListAccessor = new JListAccessor(arg.getObjectPool());
             laccessorToPrinter.put(accessor, jListAccessor);
         }
-        try {
-            result = jListAccessor.access(accessor, arg.getObjectPool(), arg.getAtype(), this);
-        } catch (Exception e) {
-            throw new AsterixException(e);
-        }
+        result = jListAccessor.access(accessor, arg.getObjectPool(), arg.getAtype(), this);
         return result;
     }
 
     @Override
-    public IJObject visit(ARecordVisitablePointable accessor, TypeInfo arg) throws AsterixException {
+    public IJObject visit(ARecordVisitablePointable accessor, TypeInfo arg) throws HyracksDataException {
         IJObject result = null;
         IJRecordAccessor jRecordAccessor = raccessorToJObject.get(accessor);
         if (jRecordAccessor == null) {
             jRecordAccessor = new JRecordAccessor(accessor.getInputRecordType(), arg.getObjectPool());
             raccessorToJObject.put(accessor, jRecordAccessor);
         }
-        try {
-            result = jRecordAccessor.access(accessor, arg.getObjectPool(), (ARecordType) arg.getAtype(), this);
-        } catch (Exception e) {
-            throw new AsterixException(e);
-        }
+        result = jRecordAccessor.access(accessor, arg.getObjectPool(), (ARecordType) arg.getAtype(), this);
         return result;
     }
 
     @Override
-    public IJObject visit(AFlatValuePointable accessor, TypeInfo arg) throws AsterixException {
+    public IJObject visit(AFlatValuePointable accessor, TypeInfo arg) throws HyracksDataException {
         ATypeTag typeTag = arg.getTypeTag();
         IJObject result = null;
         IJObjectAccessor jObjectAccessor = flatJObjectAccessors.get(typeTag);
@@ -86,11 +78,7 @@
             flatJObjectAccessors.put(typeTag, jObjectAccessor);
         }
 
-        try {
-            result = jObjectAccessor.access(accessor, arg.getObjectPool());
-        } catch (HyracksDataException e) {
-            throw new AsterixException(e);
-        }
+        result = jObjectAccessor.access(accessor, arg.getObjectPool());
         return result;
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java
index bb33fba..9e81b19 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.AListVisitablePointable;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
@@ -139,25 +138,21 @@
             if (!printFlatValue(typeTag, b, s, l, ps)) {
                 streamTag.first = ps;
                 streamTag.second = typeTag;
-                try {
-                    switch (typeTag) {
-                        case OBJECT:
-                            rPointable.set(b, s, l);
-                            visitor.visit(rPointable, streamTag);
-                            break;
-                        case ARRAY:
-                            olPointable.set(b, s, l);
-                            visitor.visit(olPointable, streamTag);
-                            break;
-                        case MULTISET:
-                            ulPointable.set(b, s, l);
-                            visitor.visit(ulPointable, streamTag);
-                            break;
-                        default:
-                            throw new HyracksDataException("No printer for type " + typeTag);
-                    }
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
+                switch (typeTag) {
+                    case OBJECT:
+                        rPointable.set(b, s, l);
+                        visitor.visit(rPointable, streamTag);
+                        break;
+                    case ARRAY:
+                        olPointable.set(b, s, l);
+                        visitor.visit(olPointable, streamTag);
+                        break;
+                    case MULTISET:
+                        ulPointable.set(b, s, l);
+                        visitor.visit(ulPointable, streamTag);
+                        break;
+                    default:
+                        throw new HyracksDataException("No printer for type " + typeTag);
                 }
             }
         };
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java
index c71225f..0eef522 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.PointableAllocator;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
@@ -59,13 +58,9 @@
 
             @Override
             public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException {
-                try {
-                    listAccessor.set(b, start, l);
-                    arg.first = ps;
-                    listAccessor.accept(printVisitor, arg);
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
-                }
+                listAccessor.set(b, start, l);
+                arg.first = ps;
+                listAccessor.accept(printVisitor, arg);
             }
         };
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java
index 4e54d3f..0ea2d96 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.PointableAllocator;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
@@ -59,13 +58,9 @@
 
             @Override
             public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException {
-                try {
-                    recAccessor.set(b, start, l);
-                    arg.first = ps;
-                    recAccessor.accept(printVisitor, arg);
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
-                }
+                recAccessor.set(b, start, l);
+                arg.first = ps;
+                recAccessor.accept(printVisitor, arg);
             }
         };
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java
index d38faf9..66f571f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.PointableAllocator;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
@@ -59,13 +58,9 @@
 
             @Override
             public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException {
-                try {
-                    listAccessor.set(b, start, l);
-                    arg.first = ps;
-                    listAccessor.accept(printVisitor, arg);
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
-                }
+                listAccessor.set(b, start, l);
+                arg.first = ps;
+                listAccessor.accept(printVisitor, arg);
             }
         };
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java
index 4018c58..2fddc83 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
 import org.apache.asterix.om.pointables.printer.IPrintVisitor;
@@ -131,17 +130,13 @@
             if (!printFlatValue(typeTag, b, s, l, ps)) {
                 streamTag.first = ps;
                 streamTag.second = typeTag;
-                try {
-                    switch (typeTag) {
-                        case OBJECT:
-                            rPointable.set(b, s, l);
-                            visitor.visit(rPointable, streamTag);
-                            break;
-                        default:
-                            throw new HyracksDataException("No printer for type " + typeTag);
-                    }
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
+                switch (typeTag) {
+                    case OBJECT:
+                        rPointable.set(b, s, l);
+                        visitor.visit(rPointable, streamTag);
+                        break;
+                    default:
+                        throw new HyracksDataException("No printer for type " + typeTag);
                 }
             }
         };
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java
index 3c4cf3e..bf55410 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.PointableAllocator;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
@@ -59,13 +58,9 @@
 
             @Override
             public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException {
-                try {
-                    recAccessor.set(b, start, l);
-                    arg.first = ps;
-                    recAccessor.accept(printVisitor, arg);
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
-                }
+                recAccessor.set(b, start, l);
+                arg.first = ps;
+                recAccessor.accept(printVisitor, arg);
             }
         };
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java
index fe089f9..624613a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.AListVisitablePointable;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
@@ -136,25 +135,21 @@
             if (!printFlatValue(typeTag, b, s, l, ps)) {
                 streamTag.first = ps;
                 streamTag.second = typeTag;
-                try {
-                    switch (typeTag) {
-                        case OBJECT:
-                            rPointable.set(b, s, l);
-                            visitor.visit(rPointable, streamTag);
-                            break;
-                        case ARRAY:
-                            olPointable.set(b, s, l);
-                            visitor.visit(olPointable, streamTag);
-                            break;
-                        case MULTISET:
-                            ulPointable.set(b, s, l);
-                            visitor.visit(ulPointable, streamTag);
-                            break;
-                        default:
-                            throw new HyracksDataException("No printer for type " + typeTag);
-                    }
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
+                switch (typeTag) {
+                    case OBJECT:
+                        rPointable.set(b, s, l);
+                        visitor.visit(rPointable, streamTag);
+                        break;
+                    case ARRAY:
+                        olPointable.set(b, s, l);
+                        visitor.visit(olPointable, streamTag);
+                        break;
+                    case MULTISET:
+                        ulPointable.set(b, s, l);
+                        visitor.visit(ulPointable, streamTag);
+                        break;
+                    default:
+                        throw new HyracksDataException("No printer for type " + typeTag);
                 }
             }
         };
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java
index 5638909..a6e3347 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.PointableAllocator;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
@@ -59,13 +58,9 @@
 
             @Override
             public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException {
-                try {
-                    listAccessor.set(b, start, l);
-                    arg.first = ps;
-                    listAccessor.accept(printVisitor, arg);
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
-                }
+                listAccessor.set(b, start, l);
+                arg.first = ps;
+                listAccessor.accept(printVisitor, arg);
             }
         };
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java
index bfad4ab..430bf66 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.PointableAllocator;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
@@ -59,13 +58,9 @@
 
             @Override
             public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException {
-                try {
-                    recAccessor.set(b, start, l);
-                    arg.first = ps;
-                    recAccessor.accept(printVisitor, arg);
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
-                }
+                recAccessor.set(b, start, l);
+                arg.first = ps;
+                recAccessor.accept(printVisitor, arg);
             }
         };
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java
index 653e483..947229c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.AListVisitablePointable;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
@@ -136,25 +135,21 @@
             if (!printFlatValue(typeTag, b, s, l, ps)) {
                 streamTag.first = ps;
                 streamTag.second = typeTag;
-                try {
-                    switch (typeTag) {
-                        case OBJECT:
-                            rPointable.set(b, s, l);
-                            visitor.visit(rPointable, streamTag);
-                            break;
-                        case ARRAY:
-                            olPointable.set(b, s, l);
-                            visitor.visit(olPointable, streamTag);
-                            break;
-                        case MULTISET:
-                            ulPointable.set(b, s, l);
-                            visitor.visit(ulPointable, streamTag);
-                            break;
-                        default:
-                            throw new HyracksDataException("No printer for type " + typeTag);
-                    }
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
+                switch (typeTag) {
+                    case OBJECT:
+                        rPointable.set(b, s, l);
+                        visitor.visit(rPointable, streamTag);
+                        break;
+                    case ARRAY:
+                        olPointable.set(b, s, l);
+                        visitor.visit(olPointable, streamTag);
+                        break;
+                    case MULTISET:
+                        ulPointable.set(b, s, l);
+                        visitor.visit(ulPointable, streamTag);
+                        break;
+                    default:
+                        throw new HyracksDataException("No printer for type " + typeTag);
                 }
             }
         };
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java
index 5f51110..7c210b6 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.PointableAllocator;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
@@ -59,13 +58,9 @@
 
             @Override
             public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException {
-                try {
-                    listAccessor.set(b, start, l);
-                    arg.first = ps;
-                    listAccessor.accept(printVisitor, arg);
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
-                }
+                listAccessor.set(b, start, l);
+                arg.first = ps;
+                listAccessor.accept(printVisitor, arg);
             }
         };
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java
index 19a03b2..4bab638 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java
@@ -20,7 +20,6 @@
 
 import java.io.PrintStream;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.PointableAllocator;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
@@ -59,13 +58,9 @@
 
             @Override
             public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException {
-                try {
-                    recAccessor.set(b, start, l);
-                    arg.first = ps;
-                    recAccessor.accept(printVisitor, arg);
-                } catch (AsterixException e) {
-                    throw new HyracksDataException(e);
-                }
+                recAccessor.set(b, start, l);
+                arg.first = ps;
+                recAccessor.accept(printVisitor, arg);
             }
         };
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AFlatValuePointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AFlatValuePointable.java
index 3f27983..86a8a29 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AFlatValuePointable.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AFlatValuePointable.java
@@ -19,11 +19,11 @@
 
 package org.apache.asterix.om.pointables;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
 import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor;
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.om.util.container.IObjectFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IValueReference;
 
 /**
@@ -79,7 +79,7 @@
     }
 
     @Override
-    public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException {
+    public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws HyracksDataException {
         return vistor.visit(this, tag);
     }
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AListVisitablePointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AListVisitablePointable.java
index ec9bf48..5b85d00 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AListVisitablePointable.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AListVisitablePointable.java
@@ -23,7 +23,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
 import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor;
@@ -35,6 +34,7 @@
 import org.apache.asterix.om.util.container.IObjectFactory;
 import org.apache.asterix.om.utils.NonTaggedFormatUtil;
 import org.apache.asterix.om.utils.ResettableByteArrayOutputStream;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 /**
  * This class interprets the binary data representation of a list, one can
@@ -157,7 +157,7 @@
     }
 
     @Override
-    public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException {
+    public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws HyracksDataException {
         return vistor.visit(this, tag);
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java
index 066d562..45e56aba 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java
@@ -24,7 +24,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
 import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor;
@@ -36,6 +35,7 @@
 import org.apache.asterix.om.util.container.IObjectFactory;
 import org.apache.asterix.om.utils.NonTaggedFormatUtil;
 import org.apache.asterix.om.utils.ResettableByteArrayOutputStream;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.util.string.UTF8StringWriter;
 
 /**
@@ -295,7 +295,7 @@
     }
 
     @Override
-    public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException {
+    public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws HyracksDataException {
         return vistor.visit(this, tag);
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/base/IVisitablePointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/base/IVisitablePointable.java
index a744856..bc5bfe5 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/base/IVisitablePointable.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/base/IVisitablePointable.java
@@ -19,8 +19,8 @@
 
 package org.apache.asterix.om.pointables.base;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IPointable;
 
 /**
@@ -29,5 +29,5 @@
  */
 public interface IVisitablePointable extends IPointable {
 
-    public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException;
+    <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws HyracksDataException;
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ACastVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ACastVisitor.java
index e57fa06..5f0b0a9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ACastVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ACastVisitor.java
@@ -23,7 +23,6 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.AFlatValuePointable;
 import org.apache.asterix.om.pointables.AListVisitablePointable;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
@@ -37,6 +36,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
 import org.apache.hyracks.algebricks.common.utils.Triple;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 
 /**
@@ -58,46 +58,38 @@
 
     @Override
     public Void visit(AListVisitablePointable accessor, Triple<IVisitablePointable, IAType, Boolean> arg)
-            throws AsterixException {
+            throws HyracksDataException {
         AListCaster caster = laccessorToCaster.get(accessor);
         if (caster == null) {
             caster = new AListCaster();
             laccessorToCaster.put(accessor, caster);
         }
-        try {
-            if (arg.second.getTypeTag().equals(ATypeTag.ANY)) {
-                arg.second = DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_TYPE;
-            }
-            caster.castList(accessor, arg.first, (AbstractCollectionType) arg.second, this);
-        } catch (Exception e) {
-            throw new AsterixException(e);
+        if (arg.second.getTypeTag().equals(ATypeTag.ANY)) {
+            arg.second = DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_TYPE;
         }
+        caster.castList(accessor, arg.first, (AbstractCollectionType) arg.second, this);
         return null;
     }
 
     @Override
     public Void visit(ARecordVisitablePointable accessor, Triple<IVisitablePointable, IAType, Boolean> arg)
-            throws AsterixException {
+            throws HyracksDataException {
         ARecordCaster caster = raccessorToCaster.get(accessor);
         if (caster == null) {
             caster = new ARecordCaster();
             raccessorToCaster.put(accessor, caster);
         }
-        try {
-            if (arg.second.getTypeTag().equals(ATypeTag.ANY)) {
-                arg.second = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
-            }
-            ARecordType resultType = (ARecordType) arg.second;
-            caster.castRecord(accessor, arg.first, resultType, this);
-        } catch (Exception e) {
-            throw new AsterixException(e);
+        if (arg.second.getTypeTag().equals(ATypeTag.ANY)) {
+            arg.second = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
         }
+        ARecordType resultType = (ARecordType) arg.second;
+        caster.castRecord(accessor, arg.first, resultType, this);
         return null;
     }
 
     @Override
     public Void visit(AFlatValuePointable accessor, Triple<IVisitablePointable, IAType, Boolean> arg)
-            throws AsterixException {
+            throws HyracksDataException {
         if (arg.second == null) {
             // for open type case
             arg.first.set(accessor);
@@ -121,7 +113,7 @@
                         accessor.getLength(), reqTypeTag, castBuffer.getDataOutput());
                 arg.first.set(castBuffer);
             } catch (IOException e1) {
-                throw new AsterixException(
+                throw new HyracksDataException(
                         "Type mismatch: cannot cast the " + inputTypeTag + " type to the " + reqTypeTag + " type.");
             }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/AListCaster.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/AListCaster.java
index 52d5b9f..9635ac7 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/AListCaster.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/AListCaster.java
@@ -26,7 +26,6 @@
 
 import org.apache.asterix.builders.OrderedListBuilder;
 import org.apache.asterix.builders.UnorderedListBuilder;
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.AListVisitablePointable;
 import org.apache.asterix.om.pointables.PointableAllocator;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
@@ -37,6 +36,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.om.utils.ResettableByteArrayOutputStream;
 import org.apache.hyracks.algebricks.common.utils.Triple;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 /**
  * This class is to do the runtime type cast for a list. It is ONLY visible to
@@ -57,7 +57,7 @@
     private IAType reqItemType;
 
     public void castList(AListVisitablePointable listAccessor, IVisitablePointable resultAccessor,
-            AbstractCollectionType reqType, ACastVisitor visitor) throws IOException, AsterixException {
+            AbstractCollectionType reqType, ACastVisitor visitor) throws HyracksDataException {
         if (reqType.getTypeTag().equals(ATypeTag.MULTISET)) {
             unOrderedListBuilder.reset(reqType);
             reqItemType = reqType.getItemType();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java
index c2aa3d8..25a2f2b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java
@@ -28,7 +28,6 @@
 import java.util.List;
 
 import org.apache.asterix.builders.RecordBuilder;
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
 import org.apache.asterix.om.pointables.PointableAllocator;
@@ -97,7 +96,7 @@
 
     private final UTF8StringWriter utf8Writer = new UTF8StringWriter();
 
-    public ARecordCaster() {
+    public ARecordCaster() throws HyracksDataException {
         try {
             bos.reset();
             int start = bos.size();
@@ -109,34 +108,34 @@
             end = bos.size();
             nullTypeTag.set(bos.getByteArray(), start, end - start);
         } catch (IOException e) {
-            throw new IllegalStateException(e);
+            throw HyracksDataException.create(e);
         }
     }
 
     public void castRecord(ARecordVisitablePointable recordAccessor, IVisitablePointable resultAccessor,
-            ARecordType reqType, ACastVisitor visitor) throws IOException {
+            ARecordType reqType, ACastVisitor visitor) throws HyracksDataException {
         List<IVisitablePointable> fieldNames = recordAccessor.getFieldNames();
         List<IVisitablePointable> fieldTypeTags = recordAccessor.getFieldTypeTags();
         List<IVisitablePointable> fieldValues = recordAccessor.getFieldValues();
         numInputFields = fieldNames.size();
 
-        try {
-            if (openFields == null || numInputFields > openFields.length) {
-                openFields = new boolean[numInputFields];
-                fieldNamesSortedIndex = new int[numInputFields];
-            }
-            if (cachedReqType == null || !reqType.equals(cachedReqType)) {
-                loadRequiredType(reqType);
-            }
-
-            // clear the previous states
-            reset();
-            matchClosedPart(fieldNames, fieldTypeTags);
-            writeOutput(fieldNames, fieldTypeTags, fieldValues, outputDos, visitor);
-            resultAccessor.set(outputBos.getByteArray(), 0, outputBos.size());
-        } catch (AsterixException e) {
-            throw new HyracksDataException("Unable to cast record to " + reqType.getTypeName(), e);
+        if (openFields == null || numInputFields > openFields.length) {
+            openFields = new boolean[numInputFields];
+            fieldNamesSortedIndex = new int[numInputFields];
         }
+        if (cachedReqType == null || !reqType.equals(cachedReqType)) {
+            try {
+                loadRequiredType(reqType);
+            } catch (IOException e) {
+                throw HyracksDataException.create(e);
+            }
+        }
+
+        // clear the previous states
+        reset();
+        matchClosedPart(fieldNames, fieldTypeTags);
+        writeOutput(fieldNames, fieldTypeTags, fieldValues, outputDos, visitor);
+        resultAccessor.set(outputBos.getByteArray(), 0, outputBos.size());
     }
 
     private void reset() {
@@ -204,7 +203,7 @@
     }
 
     private void matchClosedPart(List<IVisitablePointable> fieldNames, List<IVisitablePointable> fieldTypeTags)
-            throws AsterixException, HyracksDataException {
+            throws HyracksDataException {
         // sort-merge based match
         quickSort(fieldNamesSortedIndex, fieldNames, 0, numInputFields - 1);
         int fnStart = 0;
@@ -270,7 +269,7 @@
                 ps.print(typeTag);
 
                 //collect the output message and throw the exception
-                throw new IllegalStateException("type mismatch: including an extra field " + fieldBos.toString());
+                throw new HyracksDataException("type mismatch: including an extra field " + fieldBos.toString());
             }
         }
 
@@ -280,8 +279,8 @@
                 IAType t = cachedReqType.getFieldTypes()[i];
                 if (!NonTaggedFormatUtil.isOptional(t)) {
                     // no matched field in the input for a required closed field
-                    throw new IllegalStateException("type mismatch: missing a required closed field "
-                            + cachedReqType.getFieldNames()[i] + ":" + t.getTypeName());
+                    throw new HyracksDataException("type mismatch: missing a required closed field "
+                            + cachedReqType.getFieldNames()[i] + ": " + t.getTypeName());
                 }
             }
         }
@@ -289,7 +288,7 @@
 
     private void writeOutput(List<IVisitablePointable> fieldNames, List<IVisitablePointable> fieldTypeTags,
             List<IVisitablePointable> fieldValues, DataOutput output, ACastVisitor visitor)
-            throws IOException, AsterixException {
+            throws HyracksDataException {
         // reset the states of the record builder
         recBuilder.reset(cachedReqType);
         recBuilder.init();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java
index 704d06e..5352f3c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java
@@ -29,6 +29,7 @@
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 /**
  * This class is to print the content of a list.
@@ -47,7 +48,7 @@
     }
 
     public void printList(AListVisitablePointable listAccessor, PrintStream ps, IPrintVisitor visitor)
-            throws IOException, AsterixException {
+            throws HyracksDataException {
         List<IVisitablePointable> itemTags = listAccessor.getItemTags();
         List<IVisitablePointable> items = listAccessor.getItems();
         itemVisitorArg.first = ps;
@@ -70,7 +71,7 @@
     }
 
     private void printItem(IPrintVisitor visitor, List<IVisitablePointable> itemTags, List<IVisitablePointable> items,
-            int i) throws AsterixException {
+            int i) throws HyracksDataException {
         IVisitablePointable itemTypeTag = itemTags.get(i);
         IVisitablePointable item = items.get(i);
         ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java
index fe9e378..ef8c6da 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java
@@ -23,12 +23,12 @@
 import java.io.PrintStream;
 import java.util.List;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 /**
  * This class is to print the content of a record.
@@ -51,7 +51,7 @@
     }
 
     public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, IPrintVisitor visitor)
-            throws IOException, AsterixException {
+            throws HyracksDataException {
         final List<IVisitablePointable> fieldNames = recordAccessor.getFieldNames();
         final List<IVisitablePointable> fieldValues = recordAccessor.getFieldValues();
 
@@ -84,7 +84,7 @@
     }
 
     private void printField(PrintStream ps, IPrintVisitor visitor, IVisitablePointable fieldName,
-            IVisitablePointable fieldValue, ATypeTag fieldTypeTag) throws AsterixException {
+            IVisitablePointable fieldValue, ATypeTag fieldTypeTag) throws HyracksDataException {
         itemVisitorArg.second = fieldTypeTag;
         if (fieldNameSeparator != null) {
             // print field name
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java
index 82fe048..54bf85b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java
@@ -19,12 +19,10 @@
 
 package org.apache.asterix.om.pointables.printer;
 
-import java.io.IOException;
 import java.io.PrintStream;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.AFlatValuePointable;
 import org.apache.asterix.om.pointables.AListVisitablePointable;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
@@ -38,55 +36,44 @@
     private final Map<IVisitablePointable, AListPrinter> laccessorToPrinter = new HashMap<>();
 
     @Override
-    public Void visit(AListVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException {
+    public Void visit(AListVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws HyracksDataException {
         AListPrinter printer = laccessorToPrinter.get(accessor);
         if (printer == null) {
             printer = createListPrinter(accessor);
             laccessorToPrinter.put(accessor, printer);
         }
-        try {
-            printer.printList(accessor, arg.first, this);
-        } catch (IOException e) {
-            throw new AsterixException(e);
-        }
+        printer.printList(accessor, arg.first, this);
         return null;
     }
 
     @Override
-    public Void visit(ARecordVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException {
+    public Void visit(ARecordVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws HyracksDataException {
         ARecordPrinter printer = raccessorToPrinter.get(accessor);
         if (printer == null) {
             printer = createRecordPrinter(accessor);
             raccessorToPrinter.put(accessor, printer);
         }
-        try {
-            printer.printRecord(accessor, arg.first, this);
-        } catch (IOException e) {
-            throw new AsterixException(e);
-        }
+        printer.printRecord(accessor, arg.first, this);
         return null;
     }
 
     @Override
-    public Void visit(AFlatValuePointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException {
-        try {
-            byte[] b = accessor.getByteArray();
-            int s = accessor.getStartOffset();
-            int l = accessor.getLength();
-            PrintStream ps = arg.first;
-            ATypeTag typeTag = arg.second;
-            if (!printFlatValue(typeTag, b, s, l, ps)) {
-                throw new AsterixException("No printer for type " + typeTag);
-            }
-            return null;
-        } catch (HyracksDataException e) {
-            throw new AsterixException(e);
+    public Void visit(AFlatValuePointable accessor, Pair<PrintStream, ATypeTag> arg) throws HyracksDataException {
+        byte[] b = accessor.getByteArray();
+        int s = accessor.getStartOffset();
+        int l = accessor.getLength();
+        PrintStream ps = arg.first;
+        ATypeTag typeTag = arg.second;
+        if (!printFlatValue(typeTag, b, s, l, ps)) {
+            throw new HyracksDataException("No printer for type " + typeTag);
         }
+        return null;
     }
 
-    protected abstract AListPrinter createListPrinter(AListVisitablePointable accessor) throws AsterixException;
+    protected abstract AListPrinter createListPrinter(AListVisitablePointable accessor) throws HyracksDataException;
 
-    protected abstract ARecordPrinter createRecordPrinter(ARecordVisitablePointable accessor) throws AsterixException;
+    protected abstract ARecordPrinter createRecordPrinter(ARecordVisitablePointable accessor)
+            throws HyracksDataException;
 
     protected abstract boolean printFlatValue(ATypeTag typeTag, byte[] b, int s, int l, PrintStream ps)
             throws HyracksDataException;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java
index 926d9f0..3dba6ef 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java
@@ -38,8 +38,8 @@
  */
 public class APrintVisitor extends AbstractPrintVisitor {
     @Override
-    protected AListPrinter createListPrinter(AListVisitablePointable accessor) throws AsterixException {
-        throw new AsterixException("'List' type unsupported for CSV output");
+    protected AListPrinter createListPrinter(AListVisitablePointable accessor) throws HyracksDataException {
+        throw new HyracksDataException("'List' type unsupported for CSV output");
     }
 
     @Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/visitor/IVisitablePointableVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/visitor/IVisitablePointableVisitor.java
index 5d252ee..952533b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/visitor/IVisitablePointableVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/visitor/IVisitablePointableVisitor.java
@@ -19,10 +19,10 @@
 
 package org.apache.asterix.om.pointables.visitor;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.AFlatValuePointable;
 import org.apache.asterix.om.pointables.AListVisitablePointable;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 /**
  * This interface is a visitor for all the three different IVisitablePointable
@@ -31,9 +31,9 @@
  */
 public interface IVisitablePointableVisitor<R, T> {
 
-    public R visit(AListVisitablePointable accessor, T arg) throws AsterixException;
+    R visit(AListVisitablePointable accessor, T arg) throws HyracksDataException;
 
-    public R visit(ARecordVisitablePointable accessor, T arg) throws AsterixException;
+    R visit(ARecordVisitablePointable accessor, T arg) throws HyracksDataException;
 
-    public R visit(AFlatValuePointable accessor, T arg) throws AsterixException;
+    R visit(AFlatValuePointable accessor, T arg) throws HyracksDataException;
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java
index 2893a0c..8b0c041 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java
@@ -626,7 +626,7 @@
 
     // convert a numeric value in a byte array to the target type value
     public static void convertNumericTypeByteArray(byte[] sourceByteArray, int s1, int l1, ATypeTag targetTypeTag,
-            DataOutput out) throws AsterixException, IOException {
+            DataOutput out) throws IOException {
         ATypeTag sourceTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(sourceByteArray[s1]);
 
         if (sourceTypeTag != targetTypeTag) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/DeepEqualityVisitor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/DeepEqualityVisitor.java
index 3cf5ec9..584d1e8 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/DeepEqualityVisitor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/DeepEqualityVisitor.java
@@ -21,7 +21,6 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.pointables.AFlatValuePointable;
 import org.apache.asterix.om.pointables.AListVisitablePointable;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
@@ -40,75 +39,63 @@
 
     @Override
     public Void visit(AListVisitablePointable pointable, Pair<IVisitablePointable, Boolean> arg)
-            throws AsterixException {
+            throws HyracksDataException {
         ListDeepEqualityChecker listDeepEqualityChecker = lpointableToEquality.get(pointable);
         if (listDeepEqualityChecker == null) {
             listDeepEqualityChecker = new ListDeepEqualityChecker();
             lpointableToEquality.put(pointable, listDeepEqualityChecker);
         }
 
-        try {
-            arg.second = listDeepEqualityChecker.accessList(pointable, arg.first, this);
-        } catch (Exception e) {
-            throw new AsterixException(e);
-        }
+        arg.second = listDeepEqualityChecker.accessList(pointable, arg.first, this);
 
         return null;
     }
 
     @Override
     public Void visit(ARecordVisitablePointable pointable, Pair<IVisitablePointable, Boolean> arg)
-            throws AsterixException {
+            throws HyracksDataException {
         RecordDeepEqualityChecker recDeepEqualityChecker = rpointableToEquality.get(pointable);
         if (recDeepEqualityChecker == null) {
             recDeepEqualityChecker = new RecordDeepEqualityChecker();
             rpointableToEquality.put(pointable, recDeepEqualityChecker);
         }
 
-        try {
-            arg.second = recDeepEqualityChecker.accessRecord(pointable, arg.first, this);
-        } catch (Exception e) {
-            throw new AsterixException(e);
-        }
+        arg.second = recDeepEqualityChecker.accessRecord(pointable, arg.first, this);
 
         return null;
     }
 
     @Override
-    public Void visit(AFlatValuePointable pointable, Pair<IVisitablePointable, Boolean> arg) throws AsterixException {
+    public Void visit(AFlatValuePointable pointable, Pair<IVisitablePointable, Boolean> arg)
+            throws HyracksDataException {
 
         if (pointable.equals(arg.first)) {
             arg.second = true;
             return null;
         }
-        try {
-            ATypeTag tt1 = PointableHelper.getTypeTag(pointable);
-            ATypeTag tt2 = PointableHelper.getTypeTag(arg.first);
+        ATypeTag tt1 = PointableHelper.getTypeTag(pointable);
+        ATypeTag tt2 = PointableHelper.getTypeTag(arg.first);
 
-            if (tt1 != tt2) {
-                if (!ATypeHierarchy.isSameTypeDomain(tt1, tt2, false)) {
-                    arg.second = false;
-                } else {
-                    // If same domain, check if numberic
-                    Domain domain = ATypeHierarchy.getTypeDomain(tt1);
-                    byte b1[] = pointable.getByteArray();
-                    byte b2[] = arg.first.getByteArray();
-                    if (domain == Domain.NUMERIC) {
-                        int s1 = pointable.getStartOffset();
-                        int s2 = arg.first.getStartOffset();
-                        arg.second = Math.abs(ATypeHierarchy.getDoubleValue("deep-equal", 0, b1, s1)
-                                - ATypeHierarchy.getDoubleValue("deep-equal", 1, b2, s2)) < 1E-10;
-                    } else {
-                        arg.second = false;
-                    }
-                }
+        if (tt1 != tt2) {
+            if (!ATypeHierarchy.isSameTypeDomain(tt1, tt2, false)) {
+                arg.second = false;
             } else {
-                arg.second = PointableHelper.byteArrayEqual(pointable, arg.first, 1);
+                // If same domain, check if numberic
+                Domain domain = ATypeHierarchy.getTypeDomain(tt1);
+                byte b1[] = pointable.getByteArray();
+                byte b2[] = arg.first.getByteArray();
+                if (domain == Domain.NUMERIC) {
+                    int s1 = pointable.getStartOffset();
+                    int s2 = arg.first.getStartOffset();
+                    arg.second = Math.abs(ATypeHierarchy.getDoubleValue("deep-equal", 0, b1, s1)
+                            - ATypeHierarchy.getDoubleValue("deep-equal", 1, b2, s2)) < 1E-10;
+                } else {
+                    arg.second = false;
+                }
             }
-        } catch (HyracksDataException e) {
-            throw new AsterixException(e);
+        } else {
+            arg.second = PointableHelper.byteArrayEqual(pointable, arg.first, 1);
         }
-
         return null;
     }
 
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/ListDeepEqualityChecker.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/ListDeepEqualityChecker.java
index df4847e..bcb41f5 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/ListDeepEqualityChecker.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/ListDeepEqualityChecker.java
@@ -47,7 +47,7 @@
     }
 
     public boolean accessList(IVisitablePointable listPointableLeft, IVisitablePointable listPointableRight,
-            DeepEqualityVisitor visitor) throws IOException, AsterixException {
+            DeepEqualityVisitor visitor) throws HyracksDataException {
         this.visitor = visitor;
 
         AListVisitablePointable listLeft = (AListVisitablePointable)listPointableLeft;
@@ -74,7 +74,7 @@
 
     private boolean processOrderedList(List<IVisitablePointable> itemsLeft, List<IVisitablePointable> itemTagTypesLeft,
             List<IVisitablePointable> itemsRight, List<IVisitablePointable> itemTagTypesRight)
-            throws HyracksDataException, AsterixException {
+            throws HyracksDataException {
         for(int i=0; i<itemsLeft.size(); i++) {
             ATypeTag fieldTypeLeft = PointableHelper.getTypeTag(itemTagTypesLeft.get(i));
             if(fieldTypeLeft.isDerivedType() && fieldTypeLeft != PointableHelper.getTypeTag(itemTagTypesRight.get(i))) {
@@ -91,7 +91,7 @@
 
     private boolean processUnorderedList(List<IVisitablePointable> itemsLeft, List<IVisitablePointable> itemTagTypesLeft,
             List<IVisitablePointable> itemsRight, List<IVisitablePointable> itemTagTypesRight)
-            throws HyracksDataException, AsterixException {
+            throws HyracksDataException {
 
         hashMap.clear();
         // Build phase: Add items into hash map, starting with first list.
@@ -111,7 +111,7 @@
 
     private boolean probeHashMap(List<IVisitablePointable> itemsLeft, List<IVisitablePointable> itemTagTypesLeft,
             List<IVisitablePointable> itemsRight, List<IVisitablePointable> itemTagTypesRight)
-            throws HyracksDataException, AsterixException {
+            throws HyracksDataException {
         // Probe phase: Probe items from second list
         for(int indexRight=0; indexRight<itemsRight.size(); indexRight++) {
             IVisitablePointable itemRight = itemsRight.get(indexRight);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/RecordDeepEqualityChecker.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/RecordDeepEqualityChecker.java
index 40af09a..699f2f8 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/RecordDeepEqualityChecker.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/RecordDeepEqualityChecker.java
@@ -20,7 +20,6 @@
 
 import java.util.List;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
 import org.apache.asterix.om.pointables.base.IVisitablePointable;
@@ -50,7 +49,7 @@
     }
 
     public boolean accessRecord(IVisitablePointable recPointableLeft, IVisitablePointable recPointableRight,
-            DeepEqualityVisitor visitor) throws HyracksDataException, AsterixException {
+            DeepEqualityVisitor visitor) throws HyracksDataException {
 
         if (recPointableLeft.equals(recPointableRight)) {
             return true;
@@ -86,7 +85,7 @@
 
     private boolean compareValues(List<IVisitablePointable> fieldTypesLeft, List<IVisitablePointable> fieldValuesLeft,
             List<IVisitablePointable> fieldNamesRight, List<IVisitablePointable> fieldTypesRight,
-            List<IVisitablePointable> fieldValuesRight) throws HyracksDataException, AsterixException {
+            List<IVisitablePointable> fieldValuesRight) throws HyracksDataException {
 
         // Probe phase: Probe items from second record
         for (int i = 0; i < fieldNamesRight.size(); i++) {