Runtime ErrorCode fix in external data

1. Refactored most of the exceptions in external-data package to use
ErrorCode.
2. This change only covers RuntimeDataException/HyracksDataExcetion.
3. Refactor errorcode names

Change-Id: Ida810a56bf4aef1394879f088a6a5e8f82c60b74
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1374
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CheckInsertUpsertReturningRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CheckInsertUpsertReturningRule.java
index d181dd3..7c01ebd 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CheckInsertUpsertReturningRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CheckInsertUpsertReturningRule.java
@@ -43,7 +43,7 @@
             return false;
         }
         if (InsertUpsertCheckUtil.check(opRef.getValue())) {
-            throw new CompilationException(ErrorCode.ERROR_COMPILATION_INVALID_RETURNING_EXPRESSION);
+            throw new CompilationException(ErrorCode.COMPILATION_INVALID_RETURNING_EXPRESSION);
         }
         checked = true;
         return false;
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/CompilerExtensionManager.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/CompilerExtensionManager.java
index c994abd..95ce100 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/CompilerExtensionManager.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/CompilerExtensionManager.java
@@ -72,7 +72,7 @@
                 IExtension extension = (IExtension) Class.forName(extensionConf.getClassName()).newInstance();
                 extension.configure(extensionConf.getArgs());
                 if (extensions.containsKey(extension.getId())) {
-                    throw new RuntimeDataException(ErrorCode.ERROR_EXTENSION_ID_CONFLICT, extension.getId());
+                    throw new RuntimeDataException(ErrorCode.EXTENSION_ID_CONFLICT, extension.getId());
                 }
                 extensions.put(extension.getId(), extension);
                 switch (extension.getExtensionKind()) {
@@ -97,7 +97,7 @@
     private Pair<ExtensionId, ILangCompilationProvider> extendLangCompilationProvider(Language lang,
             Pair<ExtensionId, ILangCompilationProvider> cp, ILangExtension le) throws HyracksDataException {
         if (cp != null && le.getLangCompilationProvider(lang) != null) {
-            throw new RuntimeDataException(ErrorCode.ERROR_EXTENSION_COMPONENT_CONFLICT, le.getId(), cp.first,
+            throw new RuntimeDataException(ErrorCode.EXTENSION_COMPONENT_CONFLICT, le.getId(), cp.first,
                     lang.toString());
         }
         return (le.getLangCompilationProvider(lang) != null)
@@ -107,7 +107,7 @@
     private IStatementExecutorExtension extendStatementExecutor(IStatementExecutorExtension qte,
             IStatementExecutorExtension extension) throws HyracksDataException {
         if (qte != null) {
-            throw new RuntimeDataException(ErrorCode.ERROR_EXTENSION_COMPONENT_CONFLICT, qte.getId(), extension.getId(),
+            throw new RuntimeDataException(ErrorCode.EXTENSION_COMPONENT_CONFLICT, qte.getId(), extension.getId(),
                     IStatementExecutorFactory.class.getSimpleName());
         }
         return extension;
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCExtensionManager.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCExtensionManager.java
index fcf559f..9e32b7e 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCExtensionManager.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCExtensionManager.java
@@ -76,7 +76,7 @@
     private MetadataTupleTranslatorProvider extendTupleTranslator(MetadataTupleTranslatorProvider ttp,
             IMetadataExtension tupleTranslatorExtension, IMetadataExtension mde) throws HyracksDataException {
         if (ttp != null) {
-            throw new RuntimeDataException(ErrorCode.ERROR_EXTENSION_COMPONENT_CONFLICT,
+            throw new RuntimeDataException(ErrorCode.EXTENSION_COMPONENT_CONFLICT,
                     tupleTranslatorExtension.getId(),
                     mde.getId(), IMetadataExtension.class.getSimpleName());
         }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
index 65ec9d9..dfb6303 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -6722,7 +6722,7 @@
     <test-case FilePath="load">
       <compilation-unit name="file-not-found">
         <output-dir compare="Text">none</output-dir>
-        <expected-error>org.apache.hyracks.api.exceptions.HyracksDataException: bla: path not found</expected-error>
+        <expected-error>org.apache.hyracks.api.exceptions.HyracksDataException: ASX3077: bla: path not found</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="user-defined-functions">
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index c8785fe..0aaf8c3 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -1724,13 +1724,13 @@
     <test-case FilePath="dml">
       <compilation-unit name="load-with-autogenerated-pk_adm_02">
         <output-dir compare="Text">load-with-autogenerated-pk_adm_02</output-dir>
-        <expected-error>Parse error at (0, 5): This record is closed, you can not add extra fields! new field name: id</expected-error>
+        <expected-error>Parse error at (0, 5): ASX3058: This record is closed, you can not add extra fields! new field name: id</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="dml">
       <compilation-unit name="load-with-autogenerated-pk_adm_03">
         <output-dir compare="Text">load-with-autogenerated-pk_adm_03</output-dir>
-        <expected-error>Parse error at (0, 5): This record is closed, you can not add extra fields! new field name: id</expected-error>
+        <expected-error>Parse error at (0, 5): ASX3058: This record is closed, you can not add extra fields! new field name: id</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="dml">
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/AsterixException.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/AsterixException.java
index 53bb969..7a73705 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/AsterixException.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/AsterixException.java
@@ -20,6 +20,8 @@
 
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 
+import java.io.Serializable;
+
 public class AsterixException extends AlgebricksException {
     private static final long serialVersionUID = 1L;
 
@@ -27,10 +29,20 @@
         super(message);
     }
 
+    public AsterixException(int errorCode, Serializable... params) {
+        super(ErrorCode.ASTERIX, errorCode, ErrorCode.getErrorMessage(errorCode), params);
+
+    }
+
     public AsterixException(Throwable cause) {
         super(cause);
     }
 
+    public AsterixException(int errorCode, Throwable cause, Serializable... params) {
+        super(ErrorCode.ASTERIX, errorCode, ErrorCode.getErrorMessage(errorCode), params);
+        addSuppressed(cause);
+    }
+
     public AsterixException(String message, Throwable cause) {
         super(message, cause);
     }
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
index 2e7c69b..1289787 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
@@ -35,34 +35,115 @@
     public static final String ASTERIX = "ASX";
 
     // Extension errors
-    public static final int ERROR_EXTENSION_ID_CONFLICT = 4001;
-    public static final int ERROR_EXTENSION_COMPONENT_CONFLICT = 4002;
+    public static final int EXTENSION_ID_CONFLICT = 4001;
+    public static final int EXTENSION_COMPONENT_CONFLICT = 4002;
 
     // Runtime errors
-    public static final int ERROR_CASTING_FIELD = 1;
-    public static final int ERROR_TYPE_MISMATCH = 2;
-    public static final int ERROR_TYPE_INCOMPATIBLE = 3;
-    public static final int ERROR_TYPE_UNSUPPORTED = 4;
-    public static final int ERROR_TYPE_ITEM = 5;
-    public static final int ERROR_INVALID_FORMAT = 6;
-    public static final int ERROR_OVERFLOW = 7;
-    public static final int ERROR_UNDERFLOW = 8;
-    public static final int ERROR_INJECTED_FAILURE = 9;
-    public static final int ERROR_NEGATIVE_VALUE = 10;
-    public static final int ERROR_OUT_OF_BOUND = 11;
-    public static final int ERROR_COERCION = 12;
-    public static final int ERROR_DUPLICATE_FIELD_NAME = 13;
+    public static final int CASTING_FIELD = 1;
+    public static final int TYPE_MISMATCH = 2;
+    public static final int TYPE_INCOMPATIBLE = 3;
+    public static final int TYPE_UNSUPPORTED = 4;
+    public static final int TYPE_ITEM = 5;
+    public static final int INVALID_FORMAT = 6;
+    public static final int OVERFLOW = 7;
+    public static final int UNDERFLOW = 8;
+    public static final int INJECTED_FAILURE = 9;
+    public static final int NEGATIVE_VALUE = 10;
+    public static final int OUT_OF_BOUND = 11;
+    public static final int COERCION = 12;
+    public static final int DUPLICATE_FIELD_NAME = 13;
 
     // Compilation errors
-    public static final int ERROR_PARSE_ERROR = 1001;
-    public static final int ERROR_COMPILATION_TYPE_MISMATCH = 1002;
-    public static final int ERROR_COMPILATION_TYPE_INCOMPATIBLE = 1003;
-    public static final int ERROR_COMPILATION_TYPE_UNSUPPORTED = 1004;
-    public static final int ERROR_COMPILATION_TYPE_ITEM = 1005;
-    public static final int ERROR_COMPILATION_DUPLICATE_FIELD_NAME = 1006;
-    public static final int ERROR_COMPILATION_INVALID_EXPRESSION = 1007;
-    public static final int ERROR_COMPILATION_INVALID_PARAMETER_NUMBER = 1008;
-    public static final int ERROR_COMPILATION_INVALID_RETURNING_EXPRESSION = 1009;
+    public static final int PARSE_ERROR = 1001;
+    public static final int COMPILATION_TYPE_MISMATCH = 1002;
+    public static final int COMPILATION_TYPE_INCOMPATIBLE = 1003;
+    public static final int COMPILATION_TYPE_UNSUPPORTED = 1004;
+    public static final int COMPILATION_TYPE_ITEM = 1005;
+    public static final int COMPILATION_DUPLICATE_FIELD_NAME = 1006;
+    public static final int COMPILATION_INVALID_EXPRESSION = 1007;
+    public static final int COMPILATION_INVALID_PARAMETER_NUMBER = 1008;
+    public static final int COMPILATION_INVALID_RETURNING_EXPRESSION = 1009;
+
+    // Feed errors
+    public static final int DATAFLOW_ILLEGAL_STATE = 3001;
+    public static final int UTIL_DATAFLOW_UTILS_TUPLE_TOO_LARGE = 3002;
+    public static final int UTIL_DATAFLOW_UTILS_UNKNOWN_FORWARD_POLICY = 3003;
+    public static final int OPERATORS_FEED_INTAKE_OPERATOR_DESCRIPTOR_CLASSLOADER_NOT_CONFIGURED = 3004;
+    public static final int PARSER_DELIMITED_NONOPTIONAL_NULL = 3005;
+    public static final int PARSER_DELIMITED_ILLEGAL_FIELD = 3006;
+    public static final int FEED_MANAGEMENT_ACTIVE_LIFE_CYCLE_EVENT_SUBSCRIBER_ACTIVE_JOB_FAILURE = 3007;
+    public static final int OPERATORS_FEED_INTAKE_OPERATOR_NODE_PUSHABLE_FAIL_AT_INGESTION = 3008;
+    public static final int OPERATORS_FEED_MSG_OPERATOR_NODE_PUSHABLE_INVALID_SUBSCRIBABLE_RUNTIME = 3009;
+    public static final int PARSER_HIVE_NON_PRIMITIVE_LIST_NOT_SUPPORT = 3010;
+    public static final int PARSER_HIVE_FIELD_TYPE = 3011;
+    public static final int PARSER_HIVE_GET_COLUMNS = 3012;
+    public static final int PARSER_HIVE_NO_CLOSED_COLUMNS = 3013;
+    public static final int PARSER_HIVE_NOT_SUPPORT_NON_OP_UNION = 3014;
+    public static final int PARSER_HIVE_MISSING_FIELD_TYPE_INFO = 3015;
+    public static final int PARSER_HIVE_NULL_FIELD = 3016;
+    public static final int PARSER_HIVE_NULL_VALUE_IN_LIST = 3017;
+    public static final int INPUT_RECORD_RECORD_WITH_METADATA_AND_PK_NULL_IN_NON_OPTIONAL = 3018;
+    public static final int INPUT_RECORD_RECORD_WITH_METADATA_AND_PK_CANNT_GET_PKEY = 3019;
+    public static final int FEED_MANAGEMENT_FEED_EVENT_LISTENER_FEED_JOINT_REGISTERED = 3020;
+    public static final int FEED_MANAGEMENT_FEED_EVENT_REGISTER_INTAKE_JOB_FAIL = 3021;
+    public static final int PROVIDER_DATAFLOW_CONTROLLER_UNKNOWN_DATA_SOURCE = 3022;
+    public static final int PROVIDER_DATASOURCE_FACTORY_UNKNOWN_INPUT_STREAM_FACTORY = 3023;
+    public static final int UTIL_EXTERNAL_DATA_UTILS_FAIL_CREATE_STREAM_FACTORY = 3024;
+    public static final int UNKNOWN_RECORD_READER_FACTORY = 3025;
+    public static final int PROVIDER_STREAM_RECORD_READER_UNKNOWN_FORMAT = 3026;
+    public static final int UNKNOWN_RECORD_FORMAT_FOR_META_PARSER = 3027;
+    public static final int LIBRARY_JAVA_JOBJECTS_FIELD_ALREADY_DEFINED = 3028;
+    public static final int LIBRARY_JAVA_JOBJECTS_UNKNOWN_FIELD = 3029;
+    public static final int NODE_RESOLVER_COULDNT_RESOLVE_ADDRESS = 3030;
+    public static final int NODE_RESOLVER_NO_NODE_CONTROLLERS = 3031;
+    public static final int NODE_RESOLVER_UNABLE_RESOLVE_HOST = 3032;
+    public static final int INPUT_RECORD_CONVERTER_DCP_MSG_TO_RECORD_CONVERTER_UNKNOWN_DCP_REQUEST = 3033;
+    public static final int FEED_DATAFLOW_FRAME_DISTR_REGISTER_FAILED_DATA_PROVIDER = 3034;
+    public static final int FEED_MANAGEMENT_FEED_EVENTS_LISTENER_ALREADY_HAVE_INTAKE_JOB = 3035;
+    public static final int FEED_MANAGEMENT_FEED_EVENTS_LISTENER_INTAKE_JOB_REGISTERED = 3036;
+    public static final int FEED_MANAGEMENT_FEED_EVENTS_LISTENER_FEED_JOB_REGISTERED = 3037;
+    public static final int INPUT_RECORD_READER_CHAR_ARRAY_RECORD_TOO_LARGE = 3038;
+    public static final int LIBRARY_JOBJECT_ACCESSOR_CANNOT_PARSE_TYPE = 3039;
+    public static final int LIBRARY_JOBJECT_UTIL_ILLEGAL_ARGU_TYPE = 3040;
+    public static final int LIBRARY_EXTERNAL_FUNCTION_UNABLE_TO_LOAD_CLASS = 3041;
+    public static final int LIBRARY_EXTERNAL_FUNCTION_UNSUPPORTED_KIND = 3042;
+    public static final int LIBRARY_EXTERNAL_FUNCTION_UNKNOWN_KIND = 3043;
+    public static final int LIBRARY_EXTERNAL_LIBRARY_CLASS_REGISTERED = 3044;
+    public static final int LIBRARY_JAVA_FUNCTION_HELPER_CANNOT_HANDLE_ARGU_TYPE = 3045;
+    public static final int LIBRARY_JAVA_FUNCTION_HELPER_OBJ_TYPE_NOT_SUPPORTED = 3046;
+    public static final int LIBRARY_EXTERNAL_FUNCTION_UNSUPPORTED_NAME = 3047;
+    public static final int OPERATORS_FEED_META_OPERATOR_DESCRIPTOR_INVALID_RUNTIME = 3048;
+    public static final int PARSER_FACTORY_DELIMITED_DATA_PARSER_FACTORY_NOT_VALID_DELIMITER = 3049;
+    public static final int PARSER_FACTORY_DELIMITED_DATA_PARSER_FACTORY_NOT_VALID_QUOTE = 3050;
+    public static final int PARSER_FACTORY_DELIMITED_DATA_PARSER_FACTORY_QUOTE_DELIMITER_MISMATCH = 3051;
+    public static final int INDEXING_EXTERNAL_FILE_INDEX_ACCESSOR_UNABLE_TO_FIND_FILE_INDEX = 3052;
+    public static final int PARSER_ADM_DATA_PARSER_FIELD_NOT_NULL = 3053;
+    public static final int PARSER_ADM_DATA_PARSER_TYPE_MISMATCH = 3054;
+    public static final int PARSER_ADM_DATA_PARSER_UNEXPECTED_TOKEN_KIND = 3055;
+    public static final int PARSER_ADM_DATA_PARSER_ILLEGAL_ESCAPE = 3056;
+    public static final int PARSER_ADM_DATA_PARSER_RECORD_END_UNEXPECTED = 3057;
+    public static final int PARSER_ADM_DATA_PARSER_EXTRA_FIELD_IN_CLOSED_RECORD = 3058;
+    public static final int PARSER_ADM_DATA_PARSER_UNEXPECTED_TOKEN_WHEN_EXPECT_COMMA = 3059;
+    public static final int PARSER_ADM_DATA_PARSER_FOUND_COMMA_WHEN = 3060;
+    public static final int PARSER_ADM_DATA_PARSER_UNSUPPORTED_INTERVAL_TYPE = 3061;
+    public static final int PARSER_ADM_DATA_PARSER_INTERVAL_NOT_CLOSED = 3062;
+    public static final int PARSER_ADM_DATA_PARSER_INTERVAL_BEGIN_END_POINT_MISMATCH = 3063;
+    public static final int PARSER_ADM_DATA_PARSER_INTERVAL_MISSING_COMMA = 3064;
+    public static final int PARSER_ADM_DATA_PARSER_INTERVAL_INVALID_DATETIME = 3065;
+    public static final int PARSER_ADM_DATA_PARSER_INTERVAL_UNSUPPORTED_TYPE = 3066;
+    public static final int PARSER_ADM_DATA_PARSER_INTERVAL_INTERVAL_ARGUMENT_ERROR = 3067;
+    public static final int PARSER_ADM_DATA_PARSER_LIST_FOUND_END_COLLECTION = 3068;
+    public static final int PARSER_ADM_DATA_PARSER_LIST_FOUND_COMMA_BEFORE_LIST = 3069;
+    public static final int PARSER_ADM_DATA_PARSER_LIST_FOUND_COMMA_EXPECTING_ITEM = 3070;
+    public static final int PARSER_ADM_DATA_PARSER_LIST_FOUND_END_RECOD = 3071;
+    public static final int PARSER_ADM_DATA_PARSER_CAST_ERROR = 3072;
+    public static final int PARSER_ADM_DATA_PARSER_CONSTRUCTOR_MISSING_DESERIALIZER = 3073;
+    public static final int PARSER_ADM_DATA_PARSER_WRONG_INSTANCE = 3074;
+    public static final int PARSER_TWEET_PARSER_CLOSED_FIELD_NULL = 3075;
+    public static final int UTIL_FILE_SYSTEM_WATCHER_NO_FILES_FOUND = 3076;
+    public static final int UTIL_LOCAL_FILE_SYSTEM_UTILS_PATH_NOT_FOUND = 3077;
+    public static final int UTIL_HDFS_UTILS_CANNOT_OBTAIN_HDFS_SCHEDULER = 3078;
+
 
     // Loads the map that maps error codes to error message templates.
     private static Map<Integer, String> errorMessageMap = null;
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/library/ILibraryManager.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/library/ILibraryManager.java
index 5dca73e..3aef2c5 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/library/ILibraryManager.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/library/ILibraryManager.java
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 public interface ILibraryManager {
 
@@ -33,7 +34,8 @@
      * @param libraryName
      * @param classLoader
      */
-    public void registerLibraryClassLoader(String dataverseName, String libraryName, ClassLoader classLoader);
+    public void registerLibraryClassLoader(String dataverseName, String libraryName, ClassLoader classLoader)
+            throws HyracksDataException;
 
     /**
      * @return all registered libraries.
diff --git a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
index 85fa1d1..c072f16 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -33,18 +33,98 @@
 3,1003 = Type incompatibility: function %1$s gets incompatible input values: %2$s and %3$s
 4,1004 = Unsupported type: %1$s cannot process input type %2$s
 5,1005 = Invalid item type: function %1$s cannot process item type %2$s in an input array (or multiset)
-13,1006=Duplicate field name \"%1$s\"
-1009=A returning expression cannot contain dataset access
+13,1006 = Duplicate field name \"%1$s\"
+1009 = A returning expression cannot contain dataset access
 
 # Data errors
 6 = Invalid format for %1$s in %2$s
 7 = Overflow happend in %1$s
-8=Underflow happend in %1$s
-9=Injected failure in %1$s
-10=Invalid value: function %1$s expects its %2$s input parameter to be a non-negative value, but gets %3$s
-11=Index out of bound in %1$s: %2$s
-12=Invalid implicit scalar to collection coercion in %1$s
+8 = Underflow happend in %1$s
+9 = Injected failure in %1$s
+10 = Invalid value: function %1$s expects its %2$s input parameter to be a non-negative value, but gets %3$s
+11 = Index out of bound in %1$s: %2$s
+12 = Invalid implicit scalar to collection coercion in %1$s
 
 # Compile-time check errors
-1007=Invalid expression: function %1$s expects its %2$s input parameter to be a %3$s expression, but the actual expression is %4$s
-1008=Invalid parameter number: function %1$s cannot take %2$s parameters
+1007 = Invalid expression: function %1$s expects its %2$s input parameter to be a %3$s expression, but the actual expression is %4$s
+1008 = Invalid parameter number: function %1$s cannot take %2$s parameters
+
+# Feed Errors
+3001 = Illegal state.
+3002 = Tuple is too large for a frame
+3003 = Unknown tuple forward policy
+3004 = Unable to create adapter as class loader not configured for library %1$s in dataverse %2$s
+3005 = At record: %1$s - Field %2$s is not privatean optional type so it cannot accept null value.
+3006 = Illegal field %1$s in closed type %2$s
+3007 = Failure in active job.
+3008 = Unable to ingest data
+3009 = Invalid subscribable runtime type %1$s
+3010 = Doesn't support Hive data with list of non-primitive types
+3011 = Can't get hive type for field of type %1$s
+3012 = Failed to get columns of record
+3013 = Can't deserialize Hive records with no closed columns
+3014 = Non-optional UNION type is not supported.
+3015 = Failed to get the type information for field %1$s.
+3016 = can't parse null field
+3017 = can't parse hive list with null values
+3018 = Field %1$s of meta record is not an optional type so it cannot accept null value.
+3019 = Can't get PK from record part
+3020 = Feed joint %1$s already registered
+3021 = Could not register feed intake job [%1$s] for feed  %2$s
+3022 = Unknown data source type: %1$s
+3023 = Unknown input stream factory: %1$s
+3024 = Failed to create stream factory
+3025 = Unknown record reader factory: %1$s
+3026 = Unknown format: %1$s
+3027 = Unknown record format for a record with meta parser. Did you specify the parameter %1$s
+3028 = Field already defined in %1$s part
+3029 = Unknown field: %1$s
+3030 = Address passed: '%1$s' couldn't be resolved to an ip address and is not an NC id. Existing NCs are %2$s
+3031 = No node controllers found at the address: %1$s
+3032 = Unable to resolve hostname '%1$s' to an IP address
+3033 = Unknown DCP request: %1$s
+3034 = Attempt to register to a failed feed data provider
+3035 = Feed already has an intake job
+3036 = Feed job already registered in intake jobs
+3037 = Feed job already registered in all jobs
+3038 = Record is too large!. Maximum record size is %1$s
+3039 = Cannot parse list item of type %1$s
+3040 = Argument type: %1$s
+3041 = Unable to load/instantiate class %1$s
+3042 = UDF of kind %1$s not supported.
+3043 = Unknown function kind %1$s
+3044 = Library class loader already registered!
+3045 = Cannot handle a function argument of type %1$s
+3046 = Object of type %1$s not supported.
+3047 = External %1$s not supported
+3048 = Invalid feed runtime: %1$s
+3049 = '%1$s' is not a valid delimiter. The length of a delimiter should be 1.
+3050 = '%1$s' is not a valid quote. The length of a quote should be 1.
+3051 = Quote '%1$s' cannot be used with the delimiter '%2$s'.
+3052 = Was not able to find a file in the files index
+3053 = Field %1$s can not be null
+3054 = Mismatch Type, expecting a value of type %1$s
+3055 = Unexpected ADM token kind: %1$s.
+3056 = Illegal escape '\%1$s'
+3057 = Found END_RECORD while expecting a record field.
+3058 = This record is closed, you can not add extra fields! new field name: %1$s
+3059 = Unexpected ADM token kind: %1$s while expecting ":".
+3060 = Found COMMA %1$s %2$s record field.
+3061 = Unsupported interval type: %1$s.
+3062 = Interval was not closed.
+3063 = The interval start and end point types do not match: %1$s != %2$s
+3064 = Missing COMMA before interval end point.
+3065 = This can not be an instance of interval: missing T for a datetime value.
+3066 = Unsupported interval type: %1$s.
+3067 = Interval argument not properly constructed.
+3068 = Found END_COLLECTION while expecting a list item.
+3069 = Found COMMA before any list item.
+3070 = Found COMMA while expecting a list item.
+3071 = Found END_RECORD while expecting a list item.
+3072 = Can't cast the %1$s type to the %2$s type.
+3073 = Missing deserializer method for constructor: %1$s.
+3074 = This can not be an instance of %1$s
+3075 = Closed field %1$s has null value.
+3076 = %1$s: no files found
+3077 = %1$s: path not found
+3078 = Cannot obtain hdfs scheduler
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IFunctionHelper.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IFunctionHelper.java
index b8be685..9e57342 100755
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IFunctionHelper.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IFunctionHelper.java
@@ -31,7 +31,7 @@
 
     public boolean isValidResult();
 
-    public IJObject getObject(JTypeTag jtypeTag);
+    public IJObject getObject(JTypeTag jtypeTag) throws HyracksDataException;
 
     public void reset();
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/ILookupRecordReader.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/ILookupRecordReader.java
index fd03a07..2588f41 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/ILookupRecordReader.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/ILookupRecordReader.java
@@ -29,7 +29,7 @@
 
     public Class<?> getRecordClass() throws IOException;
 
-    public IRawRecord<T> read(RecordId rid) throws IOException, Exception;
+    public IRawRecord<T> read(RecordId rid) throws Exception;
 
     public void open() throws IOException;
 
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordDataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordDataParser.java
index bc97ed0..72adc13 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordDataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordDataParser.java
@@ -18,6 +18,8 @@
  */
 package org.apache.asterix.external.api;
 
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
 import java.io.DataOutput;
 import java.io.IOException;
 
@@ -28,5 +30,5 @@
      * @param out
      * @throws Exception
      */
-    public void parse(IRawRecord<? extends T> record, DataOutput out) throws IOException;
+    public void parse(IRawRecord<? extends T> record, DataOutput out) throws HyracksDataException;
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordWithMetadataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordWithMetadataParser.java
index 88120ed..751541d 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordWithMetadataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordWithMetadataParser.java
@@ -19,12 +19,12 @@
 package org.apache.asterix.external.api;
 
 import java.io.DataOutput;
-import java.io.IOException;
 
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
 
 public interface IRecordWithMetadataParser<T> extends IRecordDataParser<T> {
-    public void parseMeta(DataOutput out) throws IOException;
+    public void parseMeta(DataOutput out) throws HyracksDataException;
 
-    void appendLastParsedPrimaryKeyToTuple(ArrayTupleBuilder tb) throws IOException;
+    void appendLastParsedPrimaryKeyToTuple(ArrayTupleBuilder tb) throws HyracksDataException;
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordWithPKDataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordWithPKDataParser.java
index e6c114d..f5b5781 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordWithPKDataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordWithPKDataParser.java
@@ -18,11 +18,10 @@
  */
 package org.apache.asterix.external.api;
 
-import java.io.IOException;
-
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
 
 public interface IRecordWithPKDataParser<T> extends IRecordDataParser<T> {
 
-    public void appendKeys(ArrayTupleBuilder tb, IRawRecord<? extends T> record) throws IOException;
+    public void appendKeys(ArrayTupleBuilder tb, IRawRecord<? extends T> record) throws HyracksDataException;
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IStreamDataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IStreamDataParser.java
index ca274e8..aa875e1 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IStreamDataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IStreamDataParser.java
@@ -18,6 +18,8 @@
  */
 package org.apache.asterix.external.api;
 
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
 import java.io.DataOutput;
 import java.io.IOException;
 import java.io.InputStream;
@@ -38,7 +40,7 @@
      *            DataOutput instance that for writing the parser output.
      * @throws IOException
      */
-    public boolean parse(DataOutput out) throws IOException;
+    public boolean parse(DataOutput out) throws HyracksDataException;
 
     /**
      * reset the parser state. this is called when a failure takes place
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/ChangeFeedDataFlowController.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/ChangeFeedDataFlowController.java
index 7806489..d85fe65 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/ChangeFeedDataFlowController.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/ChangeFeedDataFlowController.java
@@ -41,7 +41,8 @@
     }
 
     @Override
-    protected void addPrimaryKeys(final ArrayTupleBuilder tb, final IRawRecord<? extends T> record) throws IOException {
+    protected void addPrimaryKeys(final ArrayTupleBuilder tb, final IRawRecord<? extends T> record)
+            throws HyracksDataException {
         dataParser.appendKeys(tb, record);
     }
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/ChangeFeedWithMetaDataFlowController.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/ChangeFeedWithMetaDataFlowController.java
index 7d65c52..4c88b0f 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/ChangeFeedWithMetaDataFlowController.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/ChangeFeedWithMetaDataFlowController.java
@@ -38,7 +38,8 @@
     }
 
     @Override
-    protected void addPrimaryKeys(final ArrayTupleBuilder tb, final IRawRecord<? extends T> record) throws IOException {
+    protected void addPrimaryKeys(final ArrayTupleBuilder tb, final IRawRecord<? extends T> record)
+            throws HyracksDataException {
         ((IRecordWithMetadataParser<T>) dataParser).appendLastParsedPrimaryKeyToTuple(tb);
     }
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/CounterTimerTupleForwarder.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/CounterTimerTupleForwarder.java
index db95a6a..b5adb32 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/CounterTimerTupleForwarder.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/CounterTimerTupleForwarder.java
@@ -24,6 +24,8 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.ITupleForwarder;
 import org.apache.hyracks.api.comm.IFrame;
 import org.apache.hyracks.api.comm.IFrameWriter;
@@ -110,7 +112,7 @@
             tuplesInFrame = 0;
             appender.reset(frame, true);
             if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {
-                throw new IllegalStateException();
+                throw new RuntimeDataException(ErrorCode.DATAFLOW_ILLEGAL_STATE);
             }
         }
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedWithMetaDataFlowController.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedWithMetaDataFlowController.java
index 790289a..45ae52b 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedWithMetaDataFlowController.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedWithMetaDataFlowController.java
@@ -18,8 +18,6 @@
  */
 package org.apache.asterix.external.dataflow;
 
-import java.io.IOException;
-
 import org.apache.asterix.external.api.IRawRecord;
 import org.apache.asterix.external.api.IRecordReader;
 import org.apache.asterix.external.api.IRecordWithMetadataParser;
@@ -37,7 +35,7 @@
     }
 
     @Override
-    protected void addMetaPart(ArrayTupleBuilder tb, IRawRecord<? extends T> record) throws IOException {
+    protected void addMetaPart(ArrayTupleBuilder tb, IRawRecord<? extends T> record) throws HyracksDataException {
         ((IRecordWithMetadataParser<T>) dataParser).parseMeta(tb.getDataOutput());
         tb.addFieldEndOffset();
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FrameFullTupleForwarder.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FrameFullTupleForwarder.java
index be737ae..18927cd 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FrameFullTupleForwarder.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FrameFullTupleForwarder.java
@@ -18,7 +18,9 @@
  */
 package org.apache.asterix.external.dataflow;
 
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.ITupleForwarder;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.hyracks.api.comm.IFrame;
 import org.apache.hyracks.api.comm.IFrameWriter;
 import org.apache.hyracks.api.comm.VSizeFrame;
@@ -50,7 +52,7 @@
             appender.reset(frame, true);
             success = appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize());
             if (!success) {
-                throw new IllegalStateException();
+                throw new RuntimeDataException(ErrorCode.DATAFLOW_ILLEGAL_STATE);
             }
         }
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/RateControlledTupleForwarder.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/RateControlledTupleForwarder.java
index cb80e45..eb5527f 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/RateControlledTupleForwarder.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/RateControlledTupleForwarder.java
@@ -20,6 +20,8 @@
 
 import java.util.Map;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.ITupleForwarder;
 import org.apache.hyracks.api.comm.IFrame;
 import org.apache.hyracks.api.comm.IFrameWriter;
@@ -69,7 +71,7 @@
             try {
                 Thread.sleep(interTupleInterval);
             } catch (InterruptedException e) {
-                e.printStackTrace();
+                throw new HyracksDataException(e);
             }
         }
         boolean success = appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize());
@@ -78,7 +80,7 @@
             appender.reset(frame, true);
             success = appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize());
             if (!success) {
-                throw new IllegalStateException();
+                throw new RuntimeDataException(ErrorCode.DATAFLOW_ILLEGAL_STATE);
             }
         }
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/api/IActiveLifecycleEventSubscriber.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/api/IActiveLifecycleEventSubscriber.java
index be9a245..1d8c433 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/api/IActiveLifecycleEventSubscriber.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/api/IActiveLifecycleEventSubscriber.java
@@ -18,7 +18,7 @@
  */
 package org.apache.asterix.external.feed.api;
 
-import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 public interface IActiveLifecycleEventSubscriber {
 
@@ -34,7 +34,7 @@
         ACTIVE_JOB_FAILED
     }
 
-    public void assertEvent(ActiveLifecycleEvent event) throws AsterixException, InterruptedException;
+    public void assertEvent(ActiveLifecycleEvent event) throws HyracksDataException, InterruptedException;
 
     public void handleEvent(ActiveLifecycleEvent event);
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedExceptionHandler.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedExceptionHandler.java
index 64cca8c..a8c6056 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedExceptionHandler.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedExceptionHandler.java
@@ -22,7 +22,6 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.common.exceptions.IExceptionHandler;
 import org.apache.asterix.external.util.FeedFrameUtil;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
@@ -73,7 +72,7 @@
     }
 
     // TODO: Fix logging of exceptions
-    private void logExceptionCausingTuple(int tupleIndex, Throwable e) throws HyracksDataException, AsterixException {
+    private void logExceptionCausingTuple(int tupleIndex, Throwable e) throws HyracksDataException {
         LOGGER.log(Level.WARNING, e.getMessage(), e);
     }
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FrameDistributor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FrameDistributor.java
index c8b7406..6ca4b77 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FrameDistributor.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FrameDistributor.java
@@ -24,6 +24,8 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.feed.dataflow.FeedFrameCollector.State;
 import org.apache.asterix.external.feed.management.FeedConnectionId;
 import org.apache.hyracks.api.comm.IFrameWriter;
@@ -43,7 +45,8 @@
 
     public synchronized void registerFrameCollector(FeedFrameCollector frameCollector) throws HyracksDataException {
         if (rootFailureCause != null) {
-            throw new HyracksDataException("attempt to register to a failed feed data provider", rootFailureCause);
+            throw new RuntimeDataException(ErrorCode.FEED_DATAFLOW_FRAME_DISTR_REGISTER_FAILED_DATA_PROVIDER,
+                    rootFailureCause);
         }
         // registering a new collector.
         try {
@@ -72,7 +75,8 @@
 
     public synchronized void deregisterFrameCollector(FeedConnectionId connectionId) throws HyracksDataException {
         if (rootFailureCause != null) {
-            throw new HyracksDataException("attempt to register to a failed feed data provider", rootFailureCause);
+            throw new RuntimeDataException(ErrorCode.FEED_DATAFLOW_FRAME_DISTR_REGISTER_FAILED_DATA_PROVIDER,
+                    rootFailureCause);
         }
         FeedFrameCollector frameCollector = removeFrameCollector(connectionId);
         try {
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/management/ActiveLifecycleEventSubscriber.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/management/ActiveLifecycleEventSubscriber.java
index 7f8efc5..d0eebde 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/management/ActiveLifecycleEventSubscriber.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/management/ActiveLifecycleEventSubscriber.java
@@ -21,8 +21,10 @@
 import java.util.Iterator;
 import java.util.concurrent.LinkedBlockingQueue;
 
-import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.feed.api.IActiveLifecycleEventSubscriber;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 public class ActiveLifecycleEventSubscriber implements IActiveLifecycleEventSubscriber {
 
@@ -38,7 +40,7 @@
     }
 
     @Override
-    public void assertEvent(ActiveLifecycleEvent event) throws AsterixException, InterruptedException {
+    public void assertEvent(ActiveLifecycleEvent event) throws HyracksDataException, InterruptedException {
         boolean eventOccurred = false;
         ActiveLifecycleEvent e;
         Iterator<ActiveLifecycleEvent> eventsSoFar = inbox.iterator();
@@ -57,11 +59,11 @@
         }
     }
 
-    private void assertNoFailure(ActiveLifecycleEvent e) throws AsterixException {
+    private void assertNoFailure(ActiveLifecycleEvent e) throws HyracksDataException {
         if (e.equals(ActiveLifecycleEvent.FEED_INTAKE_FAILURE) || e.equals(ActiveLifecycleEvent.FEED_COLLECT_FAILURE)
                 || e.equals(ActiveLifecycleEvent.ACTIVE_JOB_FAILED)) {
-            throw new AsterixException("Failure in active job.");
+            throw new RuntimeDataException(
+                    ErrorCode.FEED_MANAGEMENT_ACTIVE_LIFE_CYCLE_EVENT_SUBSCRIBER_ACTIVE_JOB_FAILURE);
         }
     }
-
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/management/FeedEventsListener.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/management/FeedEventsListener.java
index da26e85..64f0b8d 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/management/FeedEventsListener.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/management/FeedEventsListener.java
@@ -31,6 +31,8 @@
 import org.apache.asterix.active.EntityId;
 import org.apache.asterix.active.IActiveEntityEventsListener;
 import org.apache.asterix.common.exceptions.ACIDException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.feed.api.FeedOperationCounter;
 import org.apache.asterix.external.feed.api.IFeedJoint;
 import org.apache.asterix.external.feed.api.IFeedJoint.State;
@@ -165,9 +167,9 @@
         }
     }
 
-    public synchronized void registerFeedJoint(IFeedJoint feedJoint, int numOfPrividers) {
-        Pair<FeedOperationCounter, List<IFeedJoint>> feedJointsOnPipeline =
-                feedPipeline.get(feedJoint.getOwnerFeedId());
+    public synchronized void registerFeedJoint(IFeedJoint feedJoint, int numOfPrividers) throws HyracksDataException {
+        Pair<FeedOperationCounter, List<IFeedJoint>> feedJointsOnPipeline = feedPipeline
+                .get(feedJoint.getOwnerFeedId());
         if (feedJointsOnPipeline == null) {
             feedJointsOnPipeline = new Pair<>(new FeedOperationCounter(numOfPrividers), new ArrayList<IFeedJoint>());
             feedPipeline.put(feedJoint.getOwnerFeedId(), feedJointsOnPipeline);
@@ -176,7 +178,8 @@
             if (!feedJointsOnPipeline.second.contains(feedJoint)) {
                 feedJointsOnPipeline.second.add(feedJoint);
             } else {
-                throw new IllegalArgumentException("Feed joint " + feedJoint + " already registered");
+                throw new RuntimeDataException(
+                        ErrorCode.FEED_MANAGEMENT_FEED_EVENT_LISTENER_FEED_JOINT_REGISTERED, feedJoint);
             }
         }
     }
@@ -228,13 +231,14 @@
     public synchronized void registerFeedIntakeJob(EntityId feedId, JobId jobId, JobSpecification jobSpec)
             throws HyracksDataException {
         if (entity2Intake.get(feedId) != null) {
-            throw new IllegalStateException("Feed already has an intake job");
+            throw new RuntimeDataException(
+                    ErrorCode.FEED_MANAGEMENT_FEED_EVENTS_LISTENER_ALREADY_HAVE_INTAKE_JOB);
         }
         if (intakeJobs.get(jobId.getId()) != null) {
-            throw new IllegalStateException("Feed job already registered in intake jobs");
+            throw new RuntimeDataException(ErrorCode.FEED_MANAGEMENT_FEED_EVENTS_LISTENER_INTAKE_JOB_REGISTERED);
         }
         if (jobs.get(jobId.getId()) != null) {
-            throw new IllegalStateException("Feed job already registered in all jobs");
+            throw new RuntimeDataException(ErrorCode.FEED_MANAGEMENT_FEED_EVENTS_LISTENER_FEED_JOB_REGISTERED);
         }
 
         Pair<FeedOperationCounter, List<IFeedJoint>> pair = feedPipeline.get(feedId);
@@ -258,18 +262,18 @@
                 LOGGER.info("Registered feed intake [" + jobId + "]" + " for feed " + feedId);
             }
         } else {
-            throw new HyracksDataException(
-                    "Could not register feed intake job [" + jobId + "]" + " for feed  " + feedId);
+            throw new RuntimeDataException(ErrorCode.FEED_MANAGEMENT_FEED_EVENT_REGISTER_INTAKE_JOB_FAIL, jobId,
+                    feedId);
         }
     }
 
     public synchronized void registerFeedCollectionJob(EntityId sourceFeedId, FeedConnectionId connectionId,
-            JobId jobId, JobSpecification jobSpec, Map<String, String> feedPolicy) {
+            JobId jobId, JobSpecification jobSpec, Map<String, String> feedPolicy) throws HyracksDataException {
         if (jobs.get(jobId.getId()) != null) {
-            throw new IllegalStateException("Feed job already registered");
+            throw new RuntimeDataException(ErrorCode.FEED_MANAGEMENT_FEED_EVENTS_LISTENER_FEED_JOB_REGISTERED);
         }
         if (connectJobInfos.containsKey(jobId.getId())) {
-            throw new IllegalStateException("Feed job already registered");
+            throw new RuntimeDataException(ErrorCode.FEED_MANAGEMENT_FEED_EVENTS_LISTENER_FEED_JOB_REGISTERED);
         }
 
         List<IFeedJoint> feedJoints = feedPipeline.get(sourceFeedId).second;
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/policy/FeedPolicyEnforcer.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/policy/FeedPolicyEnforcer.java
index e0944ad..3483da4 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/policy/FeedPolicyEnforcer.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/policy/FeedPolicyEnforcer.java
@@ -18,11 +18,10 @@
  */
 package org.apache.asterix.external.feed.policy;
 
-import java.rmi.RemoteException;
 import java.util.Map;
 
-import org.apache.asterix.common.exceptions.ACIDException;
 import org.apache.asterix.external.feed.management.FeedConnectionId;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 public class FeedPolicyEnforcer {
 
@@ -34,7 +33,7 @@
         this.policyAccessor = new FeedPolicyAccessor(feedPolicy);
     }
 
-    public boolean continueIngestionPostSoftwareFailure(Exception e) throws RemoteException, ACIDException {
+    public boolean continueIngestionPostSoftwareFailure(HyracksDataException e) throws HyracksDataException {
         return policyAccessor.continueOnSoftFailure();
     }
 
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java
index 71de1b1..d01d1a8 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java
@@ -24,6 +24,8 @@
 import java.io.Serializable;
 import java.util.Date;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.operators.ExternalLookupOperatorDescriptor;
 import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
 import org.apache.asterix.om.base.ADateTime;
@@ -120,7 +122,8 @@
             setFile(externalFileRecord, file);
         } else {
             // This should never happen
-            throw new HyracksDataException("Was not able to find a file in the files index");
+            throw new RuntimeDataException(
+                    ErrorCode.INDEXING_EXTERNAL_FILE_INDEX_ACCESSOR_UNABLE_TO_FIND_FILE_INDEX);
         }
     }
 
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FileIndexTupleTranslator.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FileIndexTupleTranslator.java
index 18e5a79d..970b02a 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FileIndexTupleTranslator.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/FileIndexTupleTranslator.java
@@ -18,10 +18,7 @@
  */
 package org.apache.asterix.external.indexing;
 
-import java.io.IOException;
-
 import org.apache.asterix.builders.RecordBuilder;
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
 import org.apache.asterix.om.base.AMutableDateTime;
 import org.apache.asterix.om.base.AMutableInt32;
@@ -30,6 +27,7 @@
 import org.apache.asterix.om.base.IAObject;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
 import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference;
@@ -54,7 +52,7 @@
             .getSerializerDeserializer(BuiltinType.AINT64);
     private ArrayTupleReference tuple = new ArrayTupleReference();
 
-    public ITupleReference getTupleFromFile(ExternalFile file) throws IOException, AsterixException {
+    public ITupleReference getTupleFromFile(ExternalFile file) throws HyracksDataException {
         tupleBuilder.reset();
         //File Number
         aInt32.setValue(file.getFileNumber());
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java
index 529977a..2b899d9 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java
@@ -158,7 +158,7 @@
      * This method initialize the scheduler which assigns responsibility of reading different logical input splits from
      * HDFS
      */
-    private static void init() {
+    private static void init() throws HyracksDataException {
         if (!initialized) {
             synchronized (initLock) {
                 if (!initialized) {
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/CharArrayRecord.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/CharArrayRecord.java
index 33f9673..ff0cf84 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/CharArrayRecord.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/CharArrayRecord.java
@@ -22,6 +22,8 @@
 import java.nio.CharBuffer;
 import java.util.Arrays;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.IRawRecord;
 import org.apache.asterix.external.util.ExternalDataConstants;
 
@@ -66,8 +68,8 @@
     private void ensureCapacity(int len) throws IOException {
         if (value.length < len) {
             if (len > ExternalDataConstants.MAX_RECORD_SIZE) {
-                throw new IOException(
-                        "Record is too large!. Maximum record size is " + ExternalDataConstants.MAX_RECORD_SIZE);
+                throw new RuntimeDataException(ErrorCode.INPUT_RECORD_READER_CHAR_ARRAY_RECORD_TOO_LARGE,
+                        ExternalDataConstants.MAX_RECORD_SIZE);
             }
             int newSize = Math.min((int) (len * ExternalDataConstants.DEFAULT_BUFFER_INCREMENT_FACTOR),
                     ExternalDataConstants.MAX_RECORD_SIZE);
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/RecordWithMetadataAndPK.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/RecordWithMetadataAndPK.java
index bc5de80..c2f74e4 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/RecordWithMetadataAndPK.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/RecordWithMetadataAndPK.java
@@ -21,6 +21,8 @@
 import java.io.DataOutput;
 import java.io.IOException;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.IDataParser;
 import org.apache.asterix.external.api.IRawRecord;
 import org.apache.asterix.external.util.ExternalDataUtils;
@@ -143,8 +145,8 @@
             throws IOException {
         if (length == 0) {
             if (!NonTaggedFormatUtil.isOptional(metaTypes[index])) {
-                throw new HyracksDataException(
-                        "Field " + index + " of meta record is not an optional type so it cannot accept null value. ");
+                throw new RuntimeDataException(
+                        ErrorCode.INPUT_RECORD_RECORD_WITH_METADATA_AND_PK_NULL_IN_NON_OPTIONAL, index);
             }
             fieldValueBufferOutputs[index].writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
         } else {
@@ -154,12 +156,12 @@
     }
 
     @Override
-    public void appendPrimaryKeyToTuple(final ArrayTupleBuilder tb) throws IOException {
+    public void appendPrimaryKeyToTuple(final ArrayTupleBuilder tb) throws HyracksDataException {
         for (int i = 0; i < pkIndexes.length; i++) {
             if (keyIndicator[i] == 1) {
                 tb.addField(getMetadata(pkIndexes[i]));
             } else {
-                throw new HyracksDataException("Can't get PK from record part");
+                throw new RuntimeDataException(ErrorCode.INPUT_RECORD_RECORD_WITH_METADATA_AND_PK_CANNT_GET_PKEY);
             }
         }
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/RecordWithPK.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/RecordWithPK.java
index 02ab028..df69aa6 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/RecordWithPK.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/RecordWithPK.java
@@ -22,6 +22,7 @@
 
 import org.apache.asterix.external.api.IRawRecord;
 import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
 
@@ -86,7 +87,7 @@
         record.set(t);
     }
 
-    public void appendPrimaryKeyToTuple(final ArrayTupleBuilder tb) throws IOException {
+    public void appendPrimaryKeyToTuple(final ArrayTupleBuilder tb) throws HyracksDataException {
         for (final ArrayBackedValueStorage pkStorage : pkFieldValueBuffers) {
             tb.addField(pkStorage);
         }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/converter/DCPMessageToRecordConverter.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/converter/DCPMessageToRecordConverter.java
index 01466fd..38e5fa3 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/converter/DCPMessageToRecordConverter.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/converter/DCPMessageToRecordConverter.java
@@ -24,6 +24,8 @@
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.StandardCharsets;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.IRawRecord;
 import org.apache.asterix.external.input.record.CharArrayRecord;
 import org.apache.asterix.external.input.record.RecordWithMetadataAndPK;
@@ -31,7 +33,6 @@
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 import com.couchbase.client.core.message.dcp.DCPRequest;
 import com.couchbase.client.core.message.dcp.MutationMessage;
@@ -93,7 +94,9 @@
             recordWithMetadata.reset();
             recordWithMetadata.setMetadata(0, key);
         } else {
-            throw new HyracksDataException("Unknown DCP request: " + dcpRequest);
+            throw new RuntimeDataException(
+                    ErrorCode.INPUT_RECORD_CONVERTER_DCP_MSG_TO_RECORD_CONVERTER_UNKNOWN_DCP_REQUEST,
+                    dcpRequest.toString());
         }
         return recordWithMetadata;
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/SocketClientInputStream.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/SocketClientInputStream.java
index 4321bcd..b49c11b 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/SocketClientInputStream.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/SocketClientInputStream.java
@@ -31,7 +31,7 @@
     private final Socket socket;
     private InputStream in;
 
-    public SocketClientInputStream(Pair<String, Integer> address) throws UnknownHostException, IOException {
+    public SocketClientInputStream(Pair<String, Integer> address) throws IOException {
         this.socket = new Socket(address.first, address.second);
         this.in = socket.getInputStream();
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunction.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunction.java
index baaa731..1b89b0c 100755
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunction.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunction.java
@@ -21,7 +21,8 @@
 import java.io.IOException;
 
 import org.apache.asterix.common.api.IAppRuntimeContext;
-import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.common.library.ILibraryManager;
 import org.apache.asterix.external.api.IExternalFunction;
 import org.apache.asterix.external.api.IFunctionFactory;
@@ -86,7 +87,8 @@
             externalFunctionFactory = (IFunctionFactory) clazz.newInstance();
             externalFunction = externalFunctionFactory.getExternalFunction();
         } catch (Exception e) {
-            throw new HyracksDataException(" Unable to load/instantiate class " + classname, e);
+            throw new RuntimeDataException(ErrorCode.LIBRARY_EXTERNAL_FUNCTION_UNABLE_TO_LOAD_CLASS, e,
+                    classname);
         }
     }
 
@@ -98,7 +100,7 @@
         return finfo;
     }
 
-    public void setArguments(IFrameTupleReference tuple) throws AlgebricksException, IOException, AsterixException {
+    public void setArguments(IFrameTupleReference tuple) throws AlgebricksException, IOException {
         for (int i = 0; i < evaluatorFactories.length; i++) {
             argumentEvaluators[i].evaluate(tuple, inputVal);
 
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunctionProvider.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunctionProvider.java
index b344598..0e80e4b 100755
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunctionProvider.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunctionProvider.java
@@ -18,6 +18,8 @@
  */
 package org.apache.asterix.external.library;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.IExternalFunction;
 import org.apache.asterix.external.api.IExternalScalarFunction;
 import org.apache.asterix.external.api.IFunctionHelper;
@@ -39,9 +41,10 @@
                 return new ExternalScalarFunction(finfo, args, context);
             case AGGREGATE:
             case UNNEST:
-                throw new IllegalArgumentException(" UDF of kind" + finfo.getKind() + " not supported.");
+                throw new RuntimeDataException(ErrorCode.LIBRARY_EXTERNAL_FUNCTION_UNSUPPORTED_KIND,
+                        finfo.getKind());
             default:
-                throw new IllegalArgumentException(" unknown function kind" + finfo.getKind());
+                throw new RuntimeDataException(ErrorCode.LIBRARY_EXTERNAL_FUNCTION_UNKNOWN_KIND, finfo.getKind());
         }
     }
 }
@@ -66,7 +69,6 @@
             result.set(resultBuffer.getByteArray(), resultBuffer.getStartOffset(), resultBuffer.getLength());
             functionHelper.reset();
         } catch (Exception e) {
-            e.printStackTrace();
             throw new HyracksDataException(e);
         }
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
index 3373f70..968dbf6 100755
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
@@ -24,6 +24,8 @@
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.common.library.ILibraryManager;
 import org.apache.hyracks.algebricks.common.utils.Pair;
 
@@ -32,11 +34,12 @@
     private final Map<String, ClassLoader> libraryClassLoaders = new HashMap<>();
 
     @Override
-    public void registerLibraryClassLoader(String dataverseName, String libraryName, ClassLoader classLoader) {
+    public void registerLibraryClassLoader(String dataverseName, String libraryName, ClassLoader classLoader)
+            throws RuntimeDataException {
         String key = getKey(dataverseName, libraryName);
         synchronized (libraryClassLoaders) {
             if (libraryClassLoaders.get(key) != null) {
-                throw new IllegalStateException("Library class loader already registered!");
+                throw new RuntimeDataException(ErrorCode.LIBRARY_EXTERNAL_LIBRARY_CLASS_REGISTERED);
             }
             libraryClassLoaders.put(key, classLoader);
         }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/JavaFunctionHelper.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/JavaFunctionHelper.java
index 912192d..c1b22dc 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/JavaFunctionHelper.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/JavaFunctionHelper.java
@@ -23,6 +23,8 @@
 import java.util.Map;
 
 import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.IFunctionHelper;
 import org.apache.asterix.external.api.IJObject;
 import org.apache.asterix.external.library.java.JObjectPointableVisitor;
@@ -38,8 +40,6 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.om.util.container.IObjectPool;
 import org.apache.asterix.om.util.container.ListObjectPool;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IDataOutputProvider;
 import org.apache.hyracks.data.std.api.IValueReference;
@@ -119,7 +119,8 @@
                 jObject = pointableVisitor.visit((AListVisitablePointable) pointable, getTypeInfo(index, type));
                 break;
             case ANY:
-                throw new IllegalStateException("Cannot handle a function argument of type " + type.getTypeTag());
+                throw new RuntimeDataException(ErrorCode.LIBRARY_JAVA_FUNCTION_HELPER_CANNOT_HANDLE_ARGU_TYPE,
+                        type.getTypeTag());
             default:
                 pointable = pointableAllocator.allocateFieldValue(type);
                 pointable.set(valueReference);
@@ -147,7 +148,7 @@
     }
 
     @Override
-    public IJObject getObject(JTypeTag jtypeTag) {
+    public IJObject getObject(JTypeTag jtypeTag) throws RuntimeDataException {
         IJObject retValue = null;
         switch (jtypeTag) {
             case INT:
@@ -164,8 +165,10 @@
                 break;
             default:
                 try {
-                    throw new NotImplementedException("Object of type " + jtypeTag.name() + " not supported.");
+                    throw new RuntimeDataException(ErrorCode.LIBRARY_JAVA_FUNCTION_HELPER_OBJ_TYPE_NOT_SUPPORTED,
+                            jtypeTag.name());
                 } catch (IllegalStateException e) {
+                    // Exception is not thrown
                     e.printStackTrace();
                 }
                 break;
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/RuntimeExternalFunctionUtil.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/RuntimeExternalFunctionUtil.java
index f40bfe2..33d508e 100755
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/RuntimeExternalFunctionUtil.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/RuntimeExternalFunctionUtil.java
@@ -22,6 +22,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.om.base.AMutableInt32;
 import org.apache.asterix.om.base.AMutableString;
 import org.apache.asterix.om.base.IAObject;
@@ -29,18 +31,18 @@
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
 import org.apache.hyracks.algebricks.core.algebra.functions.IFunctionInfo;
 
 public class RuntimeExternalFunctionUtil {
 
     private static Map<String, ClassLoader> libraryClassLoaders = new HashMap<String, ClassLoader>();
 
-    public static void registerLibraryClassLoader(String dataverseName, String libraryName, ClassLoader classLoader) {
+    public static void registerLibraryClassLoader(String dataverseName, String libraryName, ClassLoader classLoader)
+            throws RuntimeDataException {
         String key = dataverseName + "." + libraryName;
         synchronized (libraryClassLoaders) {
             if (libraryClassLoaders.get(dataverseName) != null) {
-                throw new IllegalStateException("library class loader already registered!");
+                throw new RuntimeDataException(ErrorCode.LIBRARY_EXTERNAL_LIBRARY_CLASS_REGISTERED);
             }
             libraryClassLoaders.put(key, classLoader);
         }
@@ -53,15 +55,15 @@
         }
     }
 
-    public static IFunctionDescriptor getFunctionDescriptor(IFunctionInfo finfo) {
+    public static IFunctionDescriptor getFunctionDescriptor(IFunctionInfo finfo) throws RuntimeDataException {
         switch (((IExternalFunctionInfo) finfo).getKind()) {
             case SCALAR:
                 return getScalarFunctionDescriptor(finfo);
             case AGGREGATE:
             case UNNEST:
             case STATEFUL:
-                throw new NotImplementedException("External " + finfo.getFunctionIdentifier().getName()
-                        + " not supported");
+                throw new RuntimeDataException(ErrorCode.LIBRARY_EXTERNAL_FUNCTION_UNSUPPORTED_NAME,
+                        finfo.getFunctionIdentifier().getName());
         }
         return null;
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectAccessors.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectAccessors.java
index ab908bf..1f1c139 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectAccessors.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectAccessors.java
@@ -19,6 +19,8 @@
 package org.apache.asterix.external.library.java;
 
 import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
 import org.apache.asterix.dataflow.data.nontagged.serde.ACircleSerializerDeserializer;
 import org.apache.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
@@ -558,8 +560,8 @@
                             listItem = pointableVisitor.visit((AListVisitablePointable) itemPointable, typeInfo);
                             break;
                         case ANY:
-                            throw new IllegalArgumentException(
-                                    "Cannot parse list item of type " + listType.getTypeTag());
+                            throw new RuntimeDataException(ErrorCode.LIBRARY_JOBJECT_ACCESSOR_CANNOT_PARSE_TYPE,
+                                    listType.getTypeTag());
                         default:
                             listItem = pointableVisitor.visit((AFlatValuePointable) itemPointable, typeInfo);
                     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java
index ec55cf0..95e566b 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java
@@ -22,6 +22,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.dataflow.data.nontagged.serde.AStringSerializerDeserializer;
 import org.apache.asterix.dataflow.data.nontagged.serde.SerializerDeserializerUtil;
 import org.apache.asterix.external.api.IJObject;
@@ -388,7 +390,7 @@
                 }
 
             default:
-                throw new IllegalStateException("Argument type: " + typeTag);
+                throw new RuntimeDataException(ErrorCode.LIBRARY_JOBJECT_UTIL_ILLEGAL_ARGU_TYPE, typeTag);
         }
         return jObject;
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java
index ebda69c..78b14e7 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java
@@ -33,7 +33,8 @@
 import org.apache.asterix.builders.IAsterixListBuilder;
 import org.apache.asterix.builders.RecordBuilder;
 import org.apache.asterix.builders.UnorderedListBuilder;
-import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
 import org.apache.asterix.dataflow.data.nontagged.serde.ACircleSerializerDeserializer;
 import org.apache.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
@@ -990,18 +991,18 @@
             this.openFields = openFields;
         }
 
-        public void addField(String fieldName, IJObject fieldValue) throws AsterixException {
+        public void addField(String fieldName, IJObject fieldValue) throws HyracksDataException {
             int pos = getFieldPosByName(fieldName);
             if (pos >= 0) {
-                throw new AsterixException("field already defined in closed part");
+                throw new RuntimeDataException(ErrorCode.LIBRARY_JAVA_JOBJECTS_FIELD_ALREADY_DEFINED, "closed");
             }
             if (openFields.get(fieldName) != null) {
-                throw new AsterixException("field already defined in open part");
+                throw new RuntimeDataException(ErrorCode.LIBRARY_JAVA_JOBJECTS_FIELD_ALREADY_DEFINED, "open");
             }
             openFields.put(fieldName, fieldValue);
         }
 
-        public IJObject getValueByName(String fieldName) throws AsterixException, IOException {
+        public IJObject getValueByName(String fieldName) throws HyracksDataException {
             // check closed part
             int fieldPos = getFieldPosByName(fieldName);
             if (fieldPos >= 0) {
@@ -1010,7 +1011,7 @@
                 // check open part
                 IJObject fieldValue = openFields.get(fieldName);
                 if (fieldValue == null) {
-                    throw new AsterixException("unknown field: " + fieldName);
+                    throw new RuntimeDataException(ErrorCode.LIBRARY_JAVA_JOBJECTS_UNKNOWN_FIELD, fieldName);
                 }
                 return fieldValue;
             }
@@ -1025,7 +1026,7 @@
             return recordType.getTypeTag();
         }
 
-        public void setField(String fieldName, IJObject fieldValue) throws AsterixException {
+        public void setField(String fieldName, IJObject fieldValue) throws HyracksDataException {
             int pos = getFieldPosByName(fieldName);
             if (pos >= 0) {
                 fields[pos] = fieldValue;
@@ -1033,7 +1034,7 @@
                 if (openFields.get(fieldName) != null) {
                     openFields.put(fieldName, fieldValue);
                 } else {
-                    throw new AsterixException("unknown field: " + fieldName);
+                    throw new RuntimeDataException(ErrorCode.LIBRARY_JAVA_JOBJECTS_UNKNOWN_FIELD, fieldName);
                 }
             }
         }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalFilesIndexOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalFilesIndexOperatorDescriptor.java
index 02aa715..ec82ede 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalFilesIndexOperatorDescriptor.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalFilesIndexOperatorDescriptor.java
@@ -96,7 +96,6 @@
                     try {
                         IIndex index = indexHelper.getIndexInstance();
                         // Create bulk loader
-
                         IIndexBulkLoader bulkLoader = index.createBulkLoader(BTree.DEFAULT_FILL_FACTOR, false,
                                 files.size(), false);
                         // Load files
@@ -104,7 +103,7 @@
                             bulkLoader.add(filesTupleTranslator.getTupleFromFile(file));
                         }
                         bulkLoader.end();
-                    } catch (IndexException | IOException | AsterixException e) {
+                    } catch (IndexException | IOException e) {
                         throw new HyracksDataException(e);
                     } finally {
                         indexHelper.close();
@@ -132,7 +131,7 @@
                             }
                         }
                         bulkLoader.end();
-                    } catch (IndexException | IOException | AsterixException e) {
+                    } catch (IndexException | IOException e) {
                         if (bulkLoader != null) {
                             bulkLoader.abort();
                         }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorNodePushable.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorNodePushable.java
index 97a38747..237e2c0 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorNodePushable.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorNodePushable.java
@@ -58,7 +58,7 @@
                 try {
                     nonMatchWriter.writeMissing(out);
                 } catch (IOException e) {
-                    e.printStackTrace();
+                    throw new HyracksDataException(e);
                 }
                 nonMatchTupleBuild.addFieldEndOffset();
             }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedIntakeOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedIntakeOperatorDescriptor.java
index 309055a..5f478c3 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedIntakeOperatorDescriptor.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedIntakeOperatorDescriptor.java
@@ -23,6 +23,8 @@
 
 import org.apache.asterix.active.EntityId;
 import org.apache.asterix.common.api.IAppRuntimeContext;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.common.library.ILibraryManager;
 import org.apache.asterix.external.api.IAdapterFactory;
 import org.apache.asterix.external.feed.api.IFeed;
@@ -119,10 +121,11 @@
                 throw new HyracksDataException(e);
             }
         } else {
-            String message = "Unable to create adapter as class loader not configured for library " + adaptorLibraryName
-                    + " in dataverse " + feedId.getDataverse();
-            LOGGER.severe(message);
-            throw new IllegalArgumentException(message);
+            RuntimeDataException err = new RuntimeDataException(
+                    ErrorCode.OPERATORS_FEED_INTAKE_OPERATOR_DESCRIPTOR_CLASSLOADER_NOT_CONFIGURED,
+                    adaptorLibraryName, feedId.getDataverse());
+            LOGGER.severe(err.getMessage());
+            throw err;
         }
         return adapterFactory;
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedIntakeOperatorNodePushable.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedIntakeOperatorNodePushable.java
index 6f7ee15..f58e9e5 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedIntakeOperatorNodePushable.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedIntakeOperatorNodePushable.java
@@ -23,6 +23,8 @@
 import org.apache.asterix.active.EntityId;
 import org.apache.asterix.active.message.ActivePartitionMessage;
 import org.apache.asterix.common.api.IAppRuntimeContext;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.IAdapterFactory;
 import org.apache.asterix.external.dataset.adapter.FeedAdapter;
 import org.apache.asterix.external.feed.dataflow.DistributeFeedFrameWriter;
@@ -95,7 +97,8 @@
             feedManager.deregisterRuntime(ingestionRuntime.getRuntimeId());
             // If there was a failure, we need to throw an exception
             if (adapterRuntimeManager.isFailed()) {
-                throw new HyracksDataException("Unable to ingest data");
+                throw new RuntimeDataException(
+                        ErrorCode.OPERATORS_FEED_INTAKE_OPERATOR_NODE_PUSHABLE_FAIL_AT_INGESTION);
             }
         } catch (Throwable ie) {
             /*
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedMessageOperatorNodePushable.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedMessageOperatorNodePushable.java
index d1105b2..b273325 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedMessageOperatorNodePushable.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedMessageOperatorNodePushable.java
@@ -26,6 +26,8 @@
 import org.apache.asterix.active.EntityId;
 import org.apache.asterix.active.IActiveMessage;
 import org.apache.asterix.common.api.IAppRuntimeContext;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.feed.api.ISubscribableRuntime;
 import org.apache.asterix.external.feed.management.FeedConnectionId;
 import org.apache.asterix.external.feed.message.EndFeedMessage;
@@ -124,7 +126,9 @@
                     runtimeType = FeedRuntimeType.COMPUTE_COLLECT;
                     break;
                 default:
-                    throw new IllegalStateException("Invalid subscribable runtime type " + subscribableRuntimeType);
+                    throw new RuntimeDataException(
+                            ErrorCode.OPERATORS_FEED_MSG_OPERATOR_NODE_PUSHABLE_INVALID_SUBSCRIBABLE_RUNTIME,
+                            subscribableRuntimeType);
             }
 
             runtimeId = new ActiveRuntimeId(endFeedMessage.getSourceFeedId(), runtimeType.toString(), partition);
@@ -142,7 +146,9 @@
                 case INTAKE:
                     // illegal state as data hand-off from one feed to another does not happen at
                     // intake
-                    throw new IllegalStateException("Illegal State, invalid runtime type  " + subscribableRuntimeType);
+                    throw new RuntimeDataException(
+                            ErrorCode.OPERATORS_FEED_MSG_OPERATOR_NODE_PUSHABLE_INVALID_SUBSCRIBABLE_RUNTIME,
+                            subscribableRuntimeType);
                 case COMPUTE:
                     // feed could be primary or secondary, doesn't matter
                     ActiveRuntimeId feedSubscribableRuntimeId = new ActiveRuntimeId(connectionId.getFeedId(),
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedMetaOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedMetaOperatorDescriptor.java
index 908601d..d0d9f7b 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedMetaOperatorDescriptor.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/FeedMetaOperatorDescriptor.java
@@ -20,6 +20,8 @@
 
 import java.util.Map;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.feed.management.FeedConnectionId;
 import org.apache.asterix.external.util.FeedUtils.FeedRuntimeType;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
@@ -101,7 +103,8 @@
                         coreOperator, feedConnectionId, feedPolicyProperties, operandId, this);
                 break;
             default:
-                throw new HyracksDataException(new IllegalArgumentException("Invalid feed runtime: " + runtimeType));
+                throw new RuntimeDataException(ErrorCode.OPERATORS_FEED_META_OPERATOR_DESCRIPTOR_INVALID_RUNTIME,
+                        runtimeType);
         }
         return nodePushable;
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java
index 8fe11c8..d1a3ad1 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java
@@ -22,6 +22,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.Serializable;
 import java.util.BitSet;
 import java.util.List;
 
@@ -32,12 +33,12 @@
 import org.apache.asterix.builders.OrderedListBuilder;
 import org.apache.asterix.builders.RecordBuilderFactory;
 import org.apache.asterix.builders.UnorderedListBuilder;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.dataflow.data.nontagged.serde.APolygonSerializerDeserializer;
 import org.apache.asterix.external.api.IRawRecord;
 import org.apache.asterix.external.api.IRecordDataParser;
 import org.apache.asterix.external.api.IStreamDataParser;
 import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.AMutableInterval;
 import org.apache.asterix.om.base.ANull;
 import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
 import org.apache.asterix.om.types.AOrderedListType;
@@ -84,6 +85,15 @@
             super(message);
         }
 
+        public ParseException(int errorCode, Serializable... param) {
+            super(ErrorCode.ASTERIX, errorCode, ErrorCode.getErrorMessage(errorCode), param);
+        }
+
+        public ParseException(int errorCode, Throwable e, Serializable... param) {
+            super(ErrorCode.ASTERIX, errorCode, e, ErrorCode.getErrorMessage(errorCode), param);
+            addSuppressed(e);
+        }
+
         public ParseException(Throwable cause) {
             super(cause);
         }
@@ -133,7 +143,7 @@
     }
 
     @Override
-    public boolean parse(DataOutput out) throws IOException {
+    public boolean parse(DataOutput out) throws HyracksDataException {
         try {
             resetPools();
             return parseAdmInstance(recordType, out);
@@ -146,7 +156,7 @@
     }
 
     @Override
-    public void parse(IRawRecord<? extends char[]> record, DataOutput out) throws IOException {
+    public void parse(IRawRecord<? extends char[]> record, DataOutput out) throws HyracksDataException {
         try {
             resetPools();
             admLexer.setBuffer(record.get());
@@ -181,14 +191,15 @@
                 if (checkType(ATypeTag.NULL, objectType)) {
                     nullSerde.serialize(ANull.NULL, out);
                 } else {
-                    throw new ParseException("This field can not be null");
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_FIELD_NOT_NULL, "");
                 }
                 break;
             case AdmLexer.TOKEN_TRUE_LITERAL:
                 if (checkType(ATypeTag.BOOLEAN, objectType)) {
                     booleanSerde.serialize(ABoolean.TRUE, out);
                 } else {
-                    throw new ParseException(mismatchErrorMessage + objectType.getTypeName());
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_TYPE_MISMATCH,
+                            objectType.getTypeName());
                 }
                 break;
             case AdmLexer.TOKEN_BOOLEAN_CONS:
@@ -198,7 +209,8 @@
                 if (checkType(ATypeTag.BOOLEAN, objectType)) {
                     booleanSerde.serialize(ABoolean.FALSE, out);
                 } else {
-                    throw new ParseException(mismatchErrorMessage + objectType.getTypeName());
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_TYPE_MISMATCH,
+                            objectType.getTypeName());
                 }
                 break;
             case AdmLexer.TOKEN_DOUBLE_LITERAL:
@@ -255,7 +267,8 @@
                     aUUID.parseUUIDString(tokenImage);
                     uuidSerde.serialize(aUUID, out);
                 } else {
-                    throw new ParseException(mismatchErrorMessage + objectType.getTypeName());
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_TYPE_MISMATCH,
+                            objectType.getTypeName());
                 }
                 break;
             case AdmLexer.TOKEN_STRING_CONS:
@@ -273,7 +286,8 @@
                         }
                     }
                 }
-                throw new ParseException(mismatchErrorMessage + objectType.getTypeName());
+                throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_TYPE_MISMATCH,
+                        objectType.getTypeName());
             case AdmLexer.TOKEN_DATE_CONS:
                 parseConstructor(ATypeTag.DATE, objectType, out);
                 break;
@@ -288,7 +302,8 @@
                     objectType = getComplexType(objectType, ATypeTag.INTERVAL);
                     parseInterval(ATypeTag.INTERVAL, objectType, out);
                 } else {
-                    throw new ParseException(mismatchErrorMessage + objectType.getTypeName());
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_TYPE_MISMATCH,
+                            objectType.getTypeName());
                 }
                 break;
             case AdmLexer.TOKEN_DURATION_CONS:
@@ -323,7 +338,8 @@
                     objectType = getComplexType(objectType, ATypeTag.UNORDEREDLIST);
                     parseUnorderedList((AUnorderedListType) objectType, out);
                 } else {
-                    throw new ParseException(mismatchErrorMessage + objectType.getTypeName());
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_TYPE_MISMATCH,
+                            objectType.getTypeName());
                 }
                 break;
             case AdmLexer.TOKEN_START_ORDERED_LIST:
@@ -331,7 +347,8 @@
                     objectType = getComplexType(objectType, ATypeTag.ORDEREDLIST);
                     parseOrderedList((AOrderedListType) objectType, out);
                 } else {
-                    throw new ParseException(mismatchErrorMessage + objectType.getTypeName());
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_TYPE_MISMATCH,
+                            objectType.getTypeName());
                 }
                 break;
             case AdmLexer.TOKEN_START_RECORD:
@@ -339,7 +356,8 @@
                     objectType = getComplexType(objectType, ATypeTag.RECORD);
                     parseRecord((ARecordType) objectType, out);
                 } else {
-                    throw new ParseException(mismatchErrorMessage + objectType.getTypeName());
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_TYPE_MISMATCH,
+                            objectType.getTypeName());
                 }
                 break;
             case AdmLexer.TOKEN_UUID_CONS:
@@ -348,7 +366,8 @@
             case AdmLexer.TOKEN_EOF:
                 break;
             default:
-                throw new ParseException("Unexpected ADM token kind: " + AdmLexer.tokenKindToString(token) + ".");
+                throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_UNEXPECTED_TOKEN_KIND,
+                        AdmLexer.tokenKindToString(token));
         }
 
     }
@@ -388,7 +407,8 @@
                         readpos += 4;
                         break;
                     default:
-                        throw new ParseException("Illegal escape '\\" + chars[readpos + 1] + "'");
+                        throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_ILLEGAL_ESCAPE,
+                                chars[readpos + 1]);
                 }
                 ++readpos;
                 movemarker = readpos + 1;
@@ -485,7 +505,7 @@
             switch (token) {
                 case AdmLexer.TOKEN_END_RECORD:
                     if (expectingRecordField) {
-                        throw new ParseException("Found END_RECORD while expecting a record field.");
+                        throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_RECORD_END_UNEXPECTED);
                     }
                     inRecord = false;
                     break;
@@ -502,7 +522,7 @@
                         fieldId = recBuilder.getFieldId(fldName);
                         if ((fieldId < 0) && !recType.isOpen()) {
                             throw new ParseException(
-                                    "This record is closed, you can not add extra fields! new field name: " + fldName);
+                                    ErrorCode.PARSER_ADM_DATA_PARSER_EXTRA_FIELD_IN_CLOSED_RECORD, fldName);
                         } else if ((fieldId < 0) && recType.isOpen()) {
                             aStringFieldName.setValue(admLexer.getLastTokenImage().substring(1,
                                     admLexer.getLastTokenImage().length() - 1));
@@ -525,8 +545,9 @@
 
                     token = admLexer.next();
                     if (token != AdmLexer.TOKEN_COLON) {
-                        throw new ParseException("Unexpected ADM token kind: " + AdmLexer.tokenKindToString(token)
-                                + " while expecting \":\".");
+                        throw new ParseException(
+                                ErrorCode.PARSER_ADM_DATA_PARSER_UNEXPECTED_TOKEN_WHEN_EXPECT_COMMA,
+                                AdmLexer.tokenKindToString(token));
                     }
 
                     token = admLexer.next();
@@ -540,16 +561,18 @@
                     break;
                 case AdmLexer.TOKEN_COMMA:
                     if (first) {
-                        throw new ParseException("Found COMMA before any record field.");
+                        throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_FOUND_COMMA_WHEN,
+                                "before any");
                     }
                     if (expectingRecordField) {
-                        throw new ParseException("Found COMMA while expecting a record field.");
+                        throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_FOUND_COMMA_WHEN,
+                                "expecting a");
                     }
                     expectingRecordField = true;
                     break;
                 default:
-                    throw new ParseException("Unexpected ADM token kind: " + AdmLexer.tokenKindToString(token)
-                            + " while parsing record fields.");
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_UNEXPECTED_TOKEN_KIND,
+                            AdmLexer.tokenKindToString(token));
             }
             first = false;
         } while (inRecord);
@@ -557,7 +580,8 @@
         if (recType != null) {
             final int nullableFieldId = checkOptionalConstraints(recType, nulls);
             if (nullableFieldId != -1) {
-                throw new ParseException("Field: " + recType.getFieldNames()[nullableFieldId] + " can not be null");
+                throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_FIELD_NOT_NULL,
+                        recType.getFieldNames()[nullableFieldId]);
             }
         }
         recBuilder.write(out, true);
@@ -603,7 +627,8 @@
                     intervalType = ATypeTag.DATETIME;
                     break;
                 default:
-                    throw new ParseException("Unsupported interval type: " + AdmLexer.tokenKindToString(token) + ".");
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_UNSUPPORTED_INTERVAL_TYPE,
+                            AdmLexer.tokenKindToString(token));
             }
 
             // Interval
@@ -621,7 +646,7 @@
                 throw new ParseException(e);
             }
         } else {
-            throw new ParseException("Interval was not closed.");
+            throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_INTERVAL_NOT_CLOSED);
         }
         intervalSerde.serialize(aInterval, out);
     }
@@ -633,11 +658,11 @@
             if (token == startToken) {
                 return parseIntervalArgument(parseType);
             } else {
-                throw new ParseException("The interval start and end point types do not match: "
-                        + AdmLexer.tokenKindToString(startToken) + " != " + AdmLexer.tokenKindToString(token));
+                throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_INTERVAL_BEGIN_END_POINT_MISMATCH,
+                        AdmLexer.tokenKindToString(startToken), AdmLexer.tokenKindToString(token));
             }
         } else {
-            throw new ParseException("Missing COMMA before interval end point.");
+            throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_INTERVAL_MISSING_COMMA);
         }
     }
 
@@ -659,15 +684,14 @@
                     case DATETIME:
                         int timeSeperatorOffsetInDatetimeString = arg.indexOf('T');
                         if (timeSeperatorOffsetInDatetimeString < 0) {
-                            throw new ParseException(
-                                    "This can not be an instance of interval: missing T for a datetime value.");
+                            throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_INTERVAL_INVALID_DATETIME);
                         }
                         chrononTimeInMs += parseDatePart(arg, 0, timeSeperatorOffsetInDatetimeString - 1);
                         chrononTimeInMs += parseTimePart(arg, timeSeperatorOffsetInDatetimeString + 1,
                                 arg.length() - 1);
                         break;
                     default:
-                        throw new ParseException("Unsupported interval type: " + tag.name() + ".");
+                        throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_INTERVAL_UNSUPPORTED_TYPE);
                 }
                 token = admLexer.next();
                 if (token == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
@@ -675,7 +699,7 @@
                 }
             }
         }
-        throw new ParseException("Interval argument not properly constructed.");
+        throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_INTERVAL_INTERVAL_ARGUMENT_ERROR);
     }
 
     private void parseOrderedList(AOrderedListType oltype, DataOutput out) throws IOException {
@@ -696,15 +720,15 @@
             token = admLexer.next();
             if (token == AdmLexer.TOKEN_END_ORDERED_LIST) {
                 if (expectingListItem) {
-                    throw new ParseException("Found END_COLLECTION while expecting a list item.");
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_LIST_FOUND_END_COLLECTION);
                 }
                 inList = false;
             } else if (token == AdmLexer.TOKEN_COMMA) {
                 if (first) {
-                    throw new ParseException("Found COMMA before any list item.");
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_LIST_FOUND_COMMA_BEFORE_LIST);
                 }
                 if (expectingListItem) {
-                    throw new ParseException("Found COMMA while expecting a list item.");
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_LIST_FOUND_COMMA_EXPECTING_ITEM);
                 }
                 expectingListItem = true;
             } else {
@@ -739,19 +763,19 @@
             if (token == AdmLexer.TOKEN_END_RECORD) {
                 if (admLexer.next() == AdmLexer.TOKEN_END_RECORD) {
                     if (expectingListItem) {
-                        throw new ParseException("Found END_COLLECTION while expecting a list item.");
+                        throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_LIST_FOUND_END_COLLECTION);
                     } else {
                         inList = false;
                     }
                 } else {
-                    throw new ParseException("Found END_RECORD while expecting a list item.");
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_LIST_FOUND_END_RECOD);
                 }
             } else if (token == AdmLexer.TOKEN_COMMA) {
                 if (first) {
-                    throw new ParseException("Found COMMA before any list item.");
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_LIST_FOUND_COMMA_BEFORE_LIST);
                 }
                 if (expectingListItem) {
-                    throw new ParseException("Found COMMA while expecting a list item.");
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_LIST_FOUND_COMMA_EXPECTING_ITEM);
                 }
                 expectingListItem = true;
             } else {
@@ -819,7 +843,7 @@
                 // can promote typeTag to targetTypeTag
                 ITypeConvertComputer promoteComputer = ATypeHierarchy.getTypePromoteComputer(typeTag, targetTypeTag);
                 if (promoteComputer == null) {
-                    throw new ParseException("Can't cast the " + typeTag + " type to the " + targetTypeTag + " type.");
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_CAST_ERROR, typeTag, targetTypeTag);
                 }
                 // do the promotion; note that the type tag field should be skipped
                 promoteComputer.convertType(castBuffer.getByteArray(), castBuffer.getStartOffset() + 1,
@@ -828,7 +852,7 @@
                 // can demote source type to the target type
                 ITypeConvertComputer demoteComputer = ATypeHierarchy.getTypeDemoteComputer(typeTag, targetTypeTag);
                 if (demoteComputer == null) {
-                    throw new ParseException("Can't cast the " + typeTag + " type to the " + targetTypeTag + " type.");
+                    throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_CAST_ERROR, typeTag, targetTypeTag);
                 }
                 // do the demotion; note that the type tag field should be skipped
                 demoteComputer.convertType(castBuffer.getByteArray(), castBuffer.getStartOffset() + 1,
@@ -852,8 +876,9 @@
                     String unquoted = admLexer.getLastTokenImage().substring(1,
                             admLexer.getLastTokenImage().length() - 1);
                     if (!parseValue(unquoted, typeTag, dataOutput)) {
-                        throw new ParseException("Missing deserializer method for constructor: "
-                                + AdmLexer.tokenKindToString(token) + ".");
+                        throw new ParseException(
+                                ErrorCode.PARSER_ADM_DATA_PARSER_CONSTRUCTOR_MISSING_DESERIALIZER,
+                                AdmLexer.tokenKindToString(token));
                     }
                     token = admLexer.next();
                     if (token == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
@@ -872,7 +897,9 @@
                 }
             }
         }
-        throw new ParseException(mismatchErrorMessage + objectType.getTypeName() + ". Got " + typeTag + " instead.");
+
+        throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_TYPE_MISMATCH,
+                objectType.getTypeName() + " got " + typeTag);
     }
 
     private boolean parseValue(String unquoted, ATypeTag typeTag, DataOutput out) throws HyracksDataException {
@@ -950,18 +977,16 @@
     }
 
     private void parseBoolean(String bool, DataOutput out) throws HyracksDataException {
-        String errorMessage = "This can not be an instance of boolean";
         if (bool.equals("true")) {
             booleanSerde.serialize(ABoolean.TRUE, out);
         } else if (bool.equals("false")) {
             booleanSerde.serialize(ABoolean.FALSE, out);
         } else {
-            throw new ParseException(errorMessage);
+            throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_WRONG_INSTANCE, "boolean");
         }
     }
 
     private void parseInt8(String int8, DataOutput out) throws HyracksDataException {
-        String errorMessage = "This can not be an instance of int8";
         boolean positive = true;
         byte value = 0;
         int offset = 0;
@@ -979,11 +1004,11 @@
                     && ((offset + 2) == int8.length())) {
                 break;
             } else {
-                throw new ParseException(errorMessage);
+                throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_WRONG_INSTANCE, "int8");
             }
         }
         if (value < 0) {
-            throw new ParseException(errorMessage);
+            throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_WRONG_INSTANCE, "int8");
         }
         if ((value > 0) && !positive) {
             value *= -1;
@@ -993,7 +1018,6 @@
     }
 
     private void parseInt16(String int16, DataOutput out) throws HyracksDataException {
-        String errorMessage = "This can not be an instance of int16";
         boolean positive = true;
         short value = 0;
         int offset = 0;
@@ -1011,11 +1035,11 @@
                     && (int16.charAt(offset + 2) == '6') && ((offset + 3) == int16.length())) {
                 break;
             } else {
-                throw new ParseException(errorMessage);
+                throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_WRONG_INSTANCE, "int16");
             }
         }
         if (value < 0) {
-            throw new ParseException(errorMessage);
+            throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_WRONG_INSTANCE, "int16");
         }
         if ((value > 0) && !positive) {
             value *= -1;
@@ -1025,7 +1049,6 @@
     }
 
     private void parseInt32(String int32, DataOutput out) throws HyracksDataException {
-        String errorMessage = "This can not be an instance of int32";
         boolean positive = true;
         int value = 0;
         int offset = 0;
@@ -1043,11 +1066,11 @@
                     && (int32.charAt(offset + 2) == '2') && ((offset + 3) == int32.length())) {
                 break;
             } else {
-                throw new ParseException(errorMessage);
+                throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_WRONG_INSTANCE, "int32");
             }
         }
         if (value < 0) {
-            throw new ParseException(errorMessage);
+            throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_WRONG_INSTANCE, "int32");
         }
         if ((value > 0) && !positive) {
             value *= -1;
@@ -1058,7 +1081,6 @@
     }
 
     private void parseInt64(String int64, DataOutput out) throws HyracksDataException {
-        String errorMessage = "This can not be an instance of int64";
         boolean positive = true;
         long value = 0;
         int offset = 0;
@@ -1076,11 +1098,11 @@
                     && (int64.charAt(offset + 2) == '4') && ((offset + 3) == int64.length())) {
                 break;
             } else {
-                throw new ParseException(errorMessage);
+                throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_WRONG_INSTANCE, "int64");
             }
         }
         if (value < 0) {
-            throw new ParseException(errorMessage);
+            throw new ParseException(ErrorCode.PARSER_ADM_DATA_PARSER_WRONG_INSTANCE, "int64");
         }
         if ((value > 0) && !positive) {
             value *= -1;
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/DelimitedDataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/DelimitedDataParser.java
index 28fd169..b14a2c4 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/DelimitedDataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/DelimitedDataParser.java
@@ -25,10 +25,12 @@
 
 import org.apache.asterix.builders.IARecordBuilder;
 import org.apache.asterix.builders.RecordBuilder;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.IDataParser;
 import org.apache.asterix.external.api.IRawRecord;
 import org.apache.asterix.external.api.IRecordDataParser;
 import org.apache.asterix.external.api.IStreamDataParser;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.om.base.AMutableString;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.ATypeTag;
@@ -87,7 +89,7 @@
             fldIds[i] = recBuilder.getFieldId(name);
             if (fldIds[i] < 0) {
                 if (!recordType.isOpen()) {
-                    throw new HyracksDataException("Illegal field " + name + " in closed type " + recordType);
+                    throw new RuntimeDataException(ErrorCode.PARSER_DELIMITED_ILLEGAL_FIELD, name, recordType);
                 } else {
                     nameBuffers[i] = new ArrayBackedValueStorage();
                     str.setValue(name);
@@ -101,62 +103,78 @@
     }
 
     @Override
-    public boolean parse(DataOutput out) throws IOException {
-        while (cursor.nextRecord()) {
-            parseRecord(out);
-            if (!areAllNullFields) {
-                recBuilder.write(out, true);
-                return true;
+    public boolean parse(DataOutput out) throws HyracksDataException {
+        try {
+            while (cursor.nextRecord()) {
+                parseRecord();
+                if (!areAllNullFields) {
+                    recBuilder.write(out, true);
+                    return true;
+                }
             }
+            return false;
+        } catch (IOException e) {
+            throw new HyracksDataException(e);
         }
-        return false;
     }
 
-    private void parseRecord(DataOutput out) throws IOException {
+    private void parseRecord() throws HyracksDataException {
         recBuilder.reset(recordType);
         recBuilder.init();
         areAllNullFields = true;
 
         for (int i = 0; i < valueParsers.length; ++i) {
-            if (!cursor.nextField()) {
-                break;
+            try {
+                if (!cursor.nextField()) {
+                    break;
+                }
+            } catch (IOException e) {
+                throw new HyracksDataException(e);
             }
             fieldValueBuffer.reset();
 
-            if (cursor.fStart == cursor.fEnd && recordType.getFieldTypes()[i].getTypeTag() != ATypeTag.STRING
-                    && recordType.getFieldTypes()[i].getTypeTag() != ATypeTag.NULL) {
-                // if the field is empty and the type is optional, insert
-                // NULL. Note that string type can also process empty field as an
-                // empty string
-                if (!NonTaggedFormatUtil.isOptional(recordType.getFieldTypes()[i])) {
-                    throw new HyracksDataException("At record: " + cursor.recordCount + " - Field " + cursor.fieldCount
-                            + " is not an optional type so it cannot accept null value. ");
+            try {
+                if (cursor.fStart == cursor.fEnd && recordType.getFieldTypes()[i].getTypeTag() != ATypeTag.STRING
+                        && recordType.getFieldTypes()[i].getTypeTag() != ATypeTag.NULL) {
+                    // if the field is empty and the type is optional, insert
+                    // NULL. Note that string type can also process empty field as an
+                    // empty string
+                    if (!NonTaggedFormatUtil.isOptional(recordType.getFieldTypes()[i])) {
+                        throw new RuntimeDataException(ErrorCode.PARSER_DELIMITED_NONOPTIONAL_NULL,
+                                cursor.recordCount, cursor.fieldCount);
+                    }
+                    fieldValueBufferOutput.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+                } else {
+                    fieldValueBufferOutput.writeByte(fieldTypeTags[i]);
+                    // Eliminate doule quotes in the field that we are going to parse
+                    if (cursor.isDoubleQuoteIncludedInThisField) {
+                        cursor.eliminateDoubleQuote(cursor.buffer, cursor.fStart, cursor.fEnd - cursor.fStart);
+                        cursor.fEnd -= cursor.doubleQuoteCount;
+                        cursor.isDoubleQuoteIncludedInThisField = false;
+                    }
+                    valueParsers[i]
+                            .parse(cursor.buffer, cursor.fStart, cursor.fEnd - cursor.fStart, fieldValueBufferOutput);
+                    areAllNullFields = false;
                 }
-                fieldValueBufferOutput.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
-            } else {
-                fieldValueBufferOutput.writeByte(fieldTypeTags[i]);
-                // Eliminate doule quotes in the field that we are going to parse
-                if (cursor.isDoubleQuoteIncludedInThisField) {
-                    cursor.eliminateDoubleQuote(cursor.buffer, cursor.fStart, cursor.fEnd - cursor.fStart);
-                    cursor.fEnd -= cursor.doubleQuoteCount;
-                    cursor.isDoubleQuoteIncludedInThisField = false;
+                if (fldIds[i] < 0) {
+                    recBuilder.addField(nameBuffers[i], fieldValueBuffer);
+                } else {
+                    recBuilder.addField(fldIds[i], fieldValueBuffer);
                 }
-                valueParsers[i].parse(cursor.buffer, cursor.fStart, cursor.fEnd - cursor.fStart,
-                        fieldValueBufferOutput);
-                areAllNullFields = false;
-            }
-            if (fldIds[i] < 0) {
-                recBuilder.addField(nameBuffers[i], fieldValueBuffer);
-            } else {
-                recBuilder.addField(fldIds[i], fieldValueBuffer);
+            } catch (IOException e) {
+                throw new HyracksDataException(e);
             }
         }
     }
 
     @Override
-    public void parse(IRawRecord<? extends char[]> record, DataOutput out) throws IOException {
-        cursor.nextRecord(record.get(), record.size());
-        parseRecord(out);
+    public void parse(IRawRecord<? extends char[]> record, DataOutput out) throws HyracksDataException {
+        try {
+            cursor.nextRecord(record.get(), record.size());
+        } catch (IOException e) {
+            throw new HyracksDataException(e);
+        }
+        parseRecord();
         if (!areAllNullFields) {
             recBuilder.write(out, true);
         }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/HiveRecordParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/HiveRecordParser.java
index 9723461..fdcd4ff 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/HiveRecordParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/HiveRecordParser.java
@@ -27,6 +27,8 @@
 import org.apache.asterix.builders.OrderedListBuilder;
 import org.apache.asterix.builders.RecordBuilder;
 import org.apache.asterix.builders.UnorderedListBuilder;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.IRawRecord;
 import org.apache.asterix.external.api.IRecordDataParser;
 import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
@@ -54,7 +56,6 @@
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.TimestampObjectInspector;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.mapred.JobConf;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.util.string.UTF8StringWriter;
@@ -134,62 +135,66 @@
     }
 
     private void parseItem(IAType itemType, Object value, ObjectInspector foi, DataOutput dataOutput,
-            boolean primitiveOnly) throws IOException {
-        switch (itemType.getTypeTag()) {
-            case BOOLEAN:
-                parseBoolean(value, (BooleanObjectInspector) foi, dataOutput);
-                break;
-            case TIME:
-                parseTime(value, (TimestampObjectInspector) foi, dataOutput);
-                break;
-            case DATE:
-                parseDate(value, (TimestampObjectInspector) foi, dataOutput);
-                break;
-            case DATETIME:
-                parseDateTime(value, (TimestampObjectInspector) foi, dataOutput);
-                break;
-            case DOUBLE:
-                parseDouble(value, (DoubleObjectInspector) foi, dataOutput);
-                break;
-            case FLOAT:
-                parseFloat(value, (FloatObjectInspector) foi, dataOutput);
-                break;
-            case INT8:
-                parseInt8(value, (ByteObjectInspector) foi, dataOutput);
-                break;
-            case INT16:
-                parseInt16(value, (ShortObjectInspector) foi, dataOutput);
-                break;
-            case INT32:
-                parseInt32(value, (IntObjectInspector) foi, dataOutput);
-                break;
-            case INT64:
-                parseInt64(value, (LongObjectInspector) foi, dataOutput);
-                break;
-            case STRING:
-                parseString(value, (StringObjectInspector) foi, dataOutput);
-                break;
-            case ORDEREDLIST:
-                if (primitiveOnly) {
-                    throw new HyracksDataException("doesn't support hive data with list of non-primitive types");
-                }
-                parseOrderedList((AOrderedListType) itemType, value, (ListObjectInspector) foi);
-                break;
-            case UNORDEREDLIST:
-                if (primitiveOnly) {
-                    throw new HyracksDataException("doesn't support hive data with list of non-primitive types");
-                }
-                parseUnorderedList((AUnorderedListType) itemType, value, (ListObjectInspector) foi);
-                break;
-            default:
-                throw new HyracksDataException("Can't get hive type for field of type " + itemType.getTypeTag());
+            boolean primitiveOnly) throws HyracksDataException {
+        try {
+            switch (itemType.getTypeTag()) {
+                case BOOLEAN:
+                    parseBoolean(value, (BooleanObjectInspector) foi, dataOutput);
+                    break;
+                case TIME:
+                    parseTime(value, (TimestampObjectInspector) foi, dataOutput);
+                    break;
+                case DATE:
+                    parseDate(value, (TimestampObjectInspector) foi, dataOutput);
+                    break;
+                case DATETIME:
+                    parseDateTime(value, (TimestampObjectInspector) foi, dataOutput);
+                    break;
+                case DOUBLE:
+                    parseDouble(value, (DoubleObjectInspector) foi, dataOutput);
+                    break;
+                case FLOAT:
+                    parseFloat(value, (FloatObjectInspector) foi, dataOutput);
+                    break;
+                case INT8:
+                    parseInt8(value, (ByteObjectInspector) foi, dataOutput);
+                    break;
+                case INT16:
+                    parseInt16(value, (ShortObjectInspector) foi, dataOutput);
+                    break;
+                case INT32:
+                    parseInt32(value, (IntObjectInspector) foi, dataOutput);
+                    break;
+                case INT64:
+                    parseInt64(value, (LongObjectInspector) foi, dataOutput);
+                    break;
+                case STRING:
+                    parseString(value, (StringObjectInspector) foi, dataOutput);
+                    break;
+                case ORDEREDLIST:
+                    if (primitiveOnly) {
+                        throw new RuntimeDataException(ErrorCode.PARSER_HIVE_NON_PRIMITIVE_LIST_NOT_SUPPORT);
+                    }
+                    parseOrderedList((AOrderedListType) itemType, value, (ListObjectInspector) foi);
+                    break;
+                case UNORDEREDLIST:
+                    if (primitiveOnly) {
+                        throw new RuntimeDataException(ErrorCode.PARSER_HIVE_NON_PRIMITIVE_LIST_NOT_SUPPORT);
+                    }
+                    parseUnorderedList((AUnorderedListType) itemType, value, (ListObjectInspector) foi);
+                    break;
+                default:
+                    throw new RuntimeDataException(ErrorCode.PARSER_HIVE_FIELD_TYPE, itemType.getTypeTag());
+            }
+        } catch (IOException e) {
+            throw new HyracksDataException(e);
         }
     }
 
-    private Object getColTypes(ARecordType record) throws Exception {
+    private Object getColTypes(ARecordType record) throws HyracksDataException {
         int n = record.getFieldTypes().length;
         if (n < 1) {
-            throw new HyracksDataException("Failed to get columns of record");
+            throw new RuntimeDataException(ErrorCode.PARSER_HIVE_GET_COLUMNS);
         }
         //First Column
         String cols = getHiveTypeString(record.getFieldTypes(), 0);
@@ -199,9 +204,9 @@
         return cols;
     }
 
-    private String getCommaDelimitedColNames(ARecordType record) throws Exception {
+    private String getCommaDelimitedColNames(ARecordType record) throws HyracksDataException {
         if (record.getFieldNames().length < 1) {
-            throw new HyracksDataException("Can't deserialize hive records with no closed columns");
+            throw new RuntimeDataException(ErrorCode.PARSER_HIVE_NO_CLOSED_COLUMNS);
         }
 
         String cols = record.getFieldNames()[0];
@@ -211,17 +216,17 @@
         return cols;
     }
 
-    private String getHiveTypeString(IAType[] types, int i) throws Exception {
+    private String getHiveTypeString(IAType[] types, int i) throws HyracksDataException {
         final IAType type = types[i];
         ATypeTag tag = type.getTypeTag();
         if (tag == ATypeTag.UNION) {
             if (NonTaggedFormatUtil.isOptional(type)) {
-                throw new NotImplementedException("Non-optional UNION type is not supported.");
+                throw new RuntimeDataException(ErrorCode.PARSER_HIVE_NOT_SUPPORT_NON_OP_UNION);
             }
             tag = ((AUnionType) type).getActualType().getTypeTag();
         }
         if (tag == null) {
-            throw new NotImplementedException("Failed to get the type information for field " + i + ".");
+            throw new RuntimeDataException(ErrorCode.PARSER_HIVE_MISSING_FIELD_TYPE_INFO, i);
         }
         switch (tag) {
             case BOOLEAN:
@@ -251,7 +256,7 @@
             case UNORDEREDLIST:
                 return Constants.LIST_TYPE_NAME;
             default:
-                throw new HyracksDataException("Can't get hive type for field of type " + tag);
+                throw new RuntimeDataException(ErrorCode.PARSER_HIVE_FIELD_TYPE, tag);
         }
     }
 
@@ -261,7 +266,7 @@
 
     private void parseInt32(Object obj, IntObjectInspector foi, DataOutput dataOutput) throws IOException {
         if (obj == null) {
-            throw new HyracksDataException("can't parse null field");
+            throw new RuntimeDataException(ErrorCode.PARSER_HIVE_NULL_FIELD);
         }
         dataOutput.writeInt(foi.get(obj));
     }
@@ -308,7 +313,7 @@
     }
 
     private void parseOrderedList(AOrderedListType aOrderedListType, Object obj, ListObjectInspector foi)
-            throws IOException {
+            throws HyracksDataException {
         OrderedListBuilder orderedListBuilder = getOrderedListBuilder();
         IAType itemType = null;
         if (aOrderedListType != null)
@@ -320,7 +325,7 @@
             Object element = foi.getListElement(obj, i);
             ObjectInspector eoi = foi.getListElementObjectInspector();
             if (element == null) {
-                throw new HyracksDataException("can't parse hive list with null values");
+                throw new RuntimeDataException(ErrorCode.PARSER_HIVE_NULL_VALUE_IN_LIST);
             }
             parseItem(itemType, element, eoi, listItemBuffer.getDataOutput(), true);
             orderedListBuilder.addItem(listItemBuffer);
@@ -341,7 +346,7 @@
             Object element = oi.getListElement(obj, i);
             ObjectInspector eoi = oi.getListElementObjectInspector();
             if (element == null) {
-                throw new HyracksDataException("can't parse hive list with null values");
+                throw new RuntimeDataException(ErrorCode.PARSER_HIVE_NULL_VALUE_IN_LIST);
             }
             listItemBuffer.reset();
             final DataOutput dataOutput = listItemBuffer.getDataOutput();
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RSSParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RSSParser.java
index 5336c30..c2d6be8 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RSSParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RSSParser.java
@@ -30,6 +30,7 @@
 import org.apache.asterix.om.types.ARecordType;
 
 import com.sun.syndication.feed.synd.SyndEntryImpl;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 public class RSSParser implements IRecordDataParser<SyndEntryImpl> {
     private long id = 0;
@@ -49,7 +50,7 @@
     }
 
     @Override
-    public void parse(IRawRecord<? extends SyndEntryImpl> record, DataOutput out) throws IOException {
+    public void parse(IRawRecord<? extends SyndEntryImpl> record, DataOutput out) throws HyracksDataException {
         SyndEntryImpl entry = record.get();
         tupleFieldValues[0] = idPrefix + ":" + id;
         tupleFieldValues[1] = entry.getTitle();
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithMetadataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithMetadataParser.java
index 2be9019..ed33401 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithMetadataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithMetadataParser.java
@@ -107,7 +107,7 @@
     }
 
     @Override
-    public void appendLastParsedPrimaryKeyToTuple(ArrayTupleBuilder tb) throws IOException {
+    public void appendLastParsedPrimaryKeyToTuple(ArrayTupleBuilder tb) throws HyracksDataException {
         rwm.appendPrimaryKeyToTuple(tb);
     }
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithPKDataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithPKDataParser.java
index b8c265c..1f9fef2 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithPKDataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithPKDataParser.java
@@ -26,6 +26,7 @@
 import org.apache.asterix.external.api.IRecordWithPKDataParser;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
 
 public class RecordWithPKDataParser<T> implements IRecordWithPKDataParser<T> {
@@ -36,15 +37,20 @@
     }
 
     @Override
-    public void parse(IRawRecord<? extends T> record, DataOutput out) throws IOException {
+    public void parse(IRawRecord<? extends T> record, DataOutput out) throws HyracksDataException {
         if (record.size() == 0) {
-            out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+            try {
+                out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+            } catch (IOException e) {
+                throw new HyracksDataException(e);
+            }
         } else {
             recordParser.parse(record, out);
         }
     }
 
     @Override
-    public void appendKeys(ArrayTupleBuilder tb, IRawRecord<? extends T> record) throws IOException {
+    public void appendKeys(ArrayTupleBuilder tb, IRawRecord<? extends T> record) throws HyracksDataException {
+        // do nothing.
     }
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/TweetParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/TweetParser.java
index 95a5cd1..bb0b136 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/TweetParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/TweetParser.java
@@ -26,6 +26,8 @@
 import org.apache.asterix.builders.ListBuilderFactory;
 import org.apache.asterix.builders.RecordBuilderFactory;
 import org.apache.asterix.builders.UnorderedListBuilder;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.IRawRecord;
 import org.apache.asterix.external.api.IRecordDataParser;
 import org.apache.asterix.om.base.AMutablePoint;
@@ -178,8 +180,8 @@
                 DataOutput fieldOutput = fieldValueBuffer.getDataOutput();
                 if (obj.get(curFNames[iter1]).isNull()) {
                     if (curRecType.isClosedField(curFNames[iter1])) {
-                        throw new HyracksDataException("Closed field " + curFNames[iter1] + " has null value.");
-                    } else {
+                        throw new RuntimeDataException(ErrorCode.PARSER_TWEET_PARSER_CLOSED_FIELD_NULL,
+                                curFNames[iter1]);                    } else {
                         continue;
                     }
                 } else {
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/DelimitedDataParserFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/DelimitedDataParserFactory.java
index f724b48..786dac0 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/DelimitedDataParserFactory.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/DelimitedDataParserFactory.java
@@ -20,6 +20,8 @@
 
 import java.util.Map;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.IExternalDataSourceFactory.DataSourceType;
 import org.apache.asterix.external.api.IRecordDataParser;
 import org.apache.asterix.external.api.IStreamDataParser;
@@ -66,8 +68,8 @@
         if (delimiterValue == null) {
             delimiterValue = ExternalDataConstants.DEFAULT_DELIMITER;
         } else if (delimiterValue.length() != 1) {
-            throw new HyracksDataException(
-                    "'" + delimiterValue + "' is not a valid delimiter. The length of a delimiter should be 1.");
+            throw new RuntimeDataException(
+                    ErrorCode.PARSER_FACTORY_DELIMITED_DATA_PARSER_FACTORY_NOT_VALID_DELIMITER, delimiterValue);
         }
         return delimiterValue.charAt(0);
     }
@@ -79,15 +81,16 @@
         if (quoteValue == null) {
             quoteValue = ExternalDataConstants.DEFAULT_QUOTE;
         } else if (quoteValue.length() != 1) {
-            throw new HyracksDataException(
-                    "'" + quoteValue + "' is not a valid quote. The length of a quote should be 1.");
+            throw new RuntimeDataException(ErrorCode.PARSER_FACTORY_DELIMITED_DATA_PARSER_FACTORY_NOT_VALID_QUOTE,
+                    quoteValue);
         }
 
         // Since delimiter (char type value) can't be null,
         // we only check whether delimiter and quote use the same character
         if (quoteValue.charAt(0) == delimiter) {
-            throw new HyracksDataException(
-                    "Quote '" + quoteValue + "' cannot be used with the delimiter '" + delimiter + "'. ");
+            throw new RuntimeDataException(
+                    ErrorCode.PARSER_FACTORY_DELIMITED_DATA_PARSER_FACTORY_QUOTE_DELIMITER_MISMATCH, quoteValue,
+                    delimiter);
         }
 
         return quoteValue.charAt(0);
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/HiveDataParserFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/HiveDataParserFactory.java
index a4c8679..15ecbfd 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/HiveDataParserFactory.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/HiveDataParserFactory.java
@@ -20,6 +20,7 @@
 
 import java.util.Map;
 
+import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.external.api.IExternalDataSourceFactory.DataSourceType;
 import org.apache.asterix.external.api.IRecordDataParser;
 import org.apache.asterix.external.api.IRecordDataParserFactory;
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/RecordWithMetadataParserFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/RecordWithMetadataParserFactory.java
index 96c592a..484fafb 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/RecordWithMetadataParserFactory.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/factory/RecordWithMetadataParserFactory.java
@@ -21,6 +21,7 @@
 import java.util.Map;
 
 import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.external.api.IRecordDataParser;
 import org.apache.asterix.external.api.IRecordDataParserFactory;
 import org.apache.asterix.external.input.record.RecordWithMetadataAndPK;
@@ -48,14 +49,13 @@
         // validate first
         String recordFormat = configuration.get(ExternalDataConstants.KEY_RECORD_FORMAT);
         if (recordFormat == null) {
-            throw new AsterixException(
-                    "Unknown record format for a record with meta parser. Did you specify the parameter "
-                            + ExternalDataConstants.KEY_RECORD_FORMAT);
+            throw new AsterixException(ErrorCode.UNKNOWN_RECORD_FORMAT_FOR_META_PARSER,
+                    ExternalDataConstants.KEY_FORMAT);
         }
         String format = configuration.get(ExternalDataConstants.KEY_FORMAT);
         if (format == null) {
-            throw new AsterixException("Unknown format for a record with meta parser. Did you specify the parameter "
-                    + ExternalDataConstants.KEY_FORMAT);
+            throw new AsterixException(ErrorCode.UNKNOWN_RECORD_FORMAT_FOR_META_PARSER,
+                    ExternalDataConstants.KEY_FORMAT);
         }
         // Create Parser Factory
         recordParserFactory = (IRecordDataParserFactory<O>) ParserFactoryProvider.getDataParserFactory(recordFormat);
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DataflowControllerProvider.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DataflowControllerProvider.java
index 98cb4b0..a369fe3 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DataflowControllerProvider.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DataflowControllerProvider.java
@@ -22,6 +22,8 @@
 import java.util.Map;
 
 import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.AsterixInputStream;
 import org.apache.asterix.external.api.IDataFlowController;
 import org.apache.asterix.external.api.IDataParserFactory;
@@ -115,8 +117,8 @@
                                 streamParser);
                     }
                 default:
-                    throw new HyracksDataException(
-                            "Unknown data source type: " + dataSourceFactory.getDataSourceType());
+                    throw new RuntimeDataException(ErrorCode.PROVIDER_DATAFLOW_CONTROLLER_UNKNOWN_DATA_SOURCE,
+                            dataSourceFactory.getDataSourceType());
             }
         } catch (IOException | AsterixException e) {
             throw new HyracksDataException(e);
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DatasourceFactoryProvider.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DatasourceFactoryProvider.java
index 73a5302..1428863 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DatasourceFactoryProvider.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DatasourceFactoryProvider.java
@@ -20,7 +20,8 @@
 
 import java.util.Map;
 
-import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.common.library.ILibraryManager;
 import org.apache.asterix.external.api.IExternalDataSourceFactory;
 import org.apache.asterix.external.api.IExternalDataSourceFactory.DataSourceType;
@@ -35,6 +36,8 @@
 import org.apache.asterix.external.input.stream.factory.SocketServerInputStreamFactory;
 import org.apache.asterix.external.util.ExternalDataConstants;
 import org.apache.asterix.external.util.ExternalDataUtils;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 public class DatasourceFactoryProvider {
 
@@ -42,7 +45,7 @@
     }
 
     public static IExternalDataSourceFactory getExternalDataSourceFactory(ILibraryManager libraryManager,
-            Map<String, String> configuration) throws AsterixException {
+            Map<String, String> configuration) throws HyracksDataException {
         if (ExternalDataUtils.getDataSourceType(configuration).equals(DataSourceType.RECORDS)) {
             String reader = configuration.get(ExternalDataConstants.KEY_READER);
             return DatasourceFactoryProvider.getRecordReaderFactory(libraryManager, reader, configuration);
@@ -54,7 +57,7 @@
     }
 
     public static IInputStreamFactory getInputStreamFactory(ILibraryManager libraryManager, String streamSource,
-            Map<String, String> configuration) throws AsterixException {
+            Map<String, String> configuration) throws HyracksDataException {
         IInputStreamFactory streamSourceFactory;
         if (ExternalDataUtils.isExternal(streamSource)) {
             String dataverse = ExternalDataUtils.getDataverse(configuration);
@@ -76,7 +79,9 @@
                     try {
                         streamSourceFactory = (IInputStreamFactory) Class.forName(streamSource).newInstance();
                     } catch (Exception e) {
-                        throw new AsterixException("unknown input stream factory: " + streamSource, e);
+                        throw new RuntimeDataException(
+                                ErrorCode.PROVIDER_DATASOURCE_FACTORY_UNKNOWN_INPUT_STREAM_FACTORY, e,
+                                streamSource);
                     }
             }
         }
@@ -84,9 +89,14 @@
     }
 
     public static IRecordReaderFactory<?> getRecordReaderFactory(ILibraryManager libraryManager, String reader,
-            Map<String, String> configuration) throws AsterixException {
+            Map<String, String> configuration) throws HyracksDataException {
         if (reader.equals(ExternalDataConstants.EXTERNAL)) {
-            return ExternalDataUtils.createExternalRecordReaderFactory(libraryManager, configuration);
+            try {
+                return ExternalDataUtils.createExternalRecordReaderFactory(libraryManager, configuration);
+            } catch (AlgebricksException e) {
+                // Not sure whether this is the right way to handle AlgebricksException  (xikui)
+                throw new HyracksDataException(e);
+            }
         }
         switch (reader) {
             case ExternalDataConstants.READER_HDFS:
@@ -111,7 +121,7 @@
                     return (IRecordReaderFactory<?>) Class.forName(reader).newInstance();
                 } catch (IllegalAccessException | ClassNotFoundException | InstantiationException
                         | ClassCastException e) {
-                    throw new AsterixException("Unknown record reader factory: " + reader, e);
+                    throw new RuntimeDataException(ErrorCode.UNKNOWN_RECORD_READER_FACTORY, e,reader);
                 }
         }
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/StreamRecordReaderProvider.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/StreamRecordReaderProvider.java
index d11e97f..261a63c 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/StreamRecordReaderProvider.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/StreamRecordReaderProvider.java
@@ -21,6 +21,8 @@
 import java.util.Map;
 
 import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.api.AsterixInputStream;
 import org.apache.asterix.external.input.record.reader.stream.EmptyLineSeparatedRecordReader;
 import org.apache.asterix.external.input.record.reader.stream.LineRecordReader;
@@ -75,7 +77,7 @@
                         configuration.get(ExternalDataConstants.KEY_RECORD_START),
                         configuration.get(ExternalDataConstants.KEY_RECORD_END));
             default:
-                throw new HyracksDataException("Unknown format: " + format);
+                throw new RuntimeDataException(ErrorCode.PROVIDER_STREAM_RECORD_READER_UNKNOWN_FORMAT, format);
         }
     }
 }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/DataflowUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/DataflowUtils.java
index ed811ad..31a223f 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/DataflowUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/DataflowUtils.java
@@ -20,6 +20,8 @@
 
 import java.util.Map;
 
+import org.apache.asterix.common.exceptions.RuntimeDataException;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.external.api.ITupleForwarder;
 import org.apache.asterix.external.api.ITupleForwarder.TupleForwardPolicy;
 import org.apache.asterix.external.dataflow.CounterTimerTupleForwarder;
@@ -38,7 +40,7 @@
         if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {
             appender.write(writer, true);
             if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {
-                throw new HyracksDataException("Tuple is too large for a frame");
+                throw new RuntimeDataException(ErrorCode.UTIL_DATAFLOW_UTILS_TUPLE_TOO_LARGE);
             }
         }
     }
@@ -65,7 +67,7 @@
             case RATE_CONTROLLED:
                 return RateControlledTupleForwarder.create(configuration);
             default:
-                throw new HyracksDataException("Unknown tuple forward policy");
+                throw new RuntimeDataException(ErrorCode.UTIL_DATAFLOW_UTILS_UNKNOWN_FORWARD_POLICY);
         }
     }
 
@@ -74,7 +76,7 @@
         if (!appender.append(tuple)) {
             appender.write(writer, true);
             if (!appender.append(tuple)) {
-                throw new HyracksDataException("Tuple is too large for a frame");
+                throw new RuntimeDataException(ErrorCode.UTIL_DATAFLOW_UTILS_TUPLE_TOO_LARGE);
             }
         }
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
index 8eb8815..d009960 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
@@ -22,6 +22,8 @@
 import java.util.Map;
 
 import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.common.library.ILibraryManager;
 import org.apache.asterix.external.api.IDataParserFactory;
 import org.apache.asterix.external.api.IExternalDataSourceFactory.DataSourceType;
@@ -31,6 +33,7 @@
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.AUnionType;
 import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.dataflow.common.data.parsers.DoubleParserFactory;
 import org.apache.hyracks.dataflow.common.data.parsers.FloatParserFactory;
 import org.apache.hyracks.dataflow.common.data.parsers.IValueParserFactory;
@@ -127,14 +130,14 @@
     }
 
     public static IInputStreamFactory createExternalInputStreamFactory(ILibraryManager libraryManager, String dataverse,
-            String stream) throws AsterixException {
+            String stream) throws HyracksDataException {
         try {
             String libraryName = getLibraryName(stream);
             String className = getExternalClassName(stream);
             ClassLoader classLoader = getClassLoader(libraryManager, dataverse, libraryName);
             return ((IInputStreamFactory) (classLoader.loadClass(className).newInstance()));
         } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
-            throw new AsterixException("Failed to create stream factory", e);
+            throw new RuntimeDataException(ErrorCode.UTIL_EXTERNAL_DATA_UTILS_FAIL_CREATE_STREAM_FACTORY, e);
         }
     }
 
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
index ea5cc8f..258f194 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
@@ -36,6 +36,8 @@
 import java.util.List;
 import java.util.concurrent.locks.ReentrantLock;
 
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
@@ -95,7 +97,8 @@
                     resume();
                 } else {
                     if (files.isEmpty()) {
-                        throw new HyracksDataException(path + ": no files found");
+                        throw new RuntimeDataException(ErrorCode.UTIL_FILE_SYSTEM_WATCHER_NO_FILES_FOUND,
+                                path.toString());
                     }
                 }
             }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
index 826a396..42b582b 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
@@ -25,6 +25,8 @@
 import java.util.Map;
 
 import org.apache.asterix.common.config.DatasetConfig.ExternalFilePendingOp;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.external.indexing.ExternalFile;
 import org.apache.asterix.external.indexing.IndexingScheduler;
 import org.apache.asterix.external.indexing.RecordId.RecordIdType;
@@ -43,31 +45,32 @@
 import org.apache.hadoop.mapred.TextInputFormat;
 import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
 import org.apache.hyracks.api.context.ICCContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.exceptions.HyracksException;
 import org.apache.hyracks.hdfs.scheduler.Scheduler;
 
 public class HDFSUtils {
 
-    public static Scheduler initializeHDFSScheduler() {
+    public static Scheduler initializeHDFSScheduler() throws  HyracksDataException {
         ICCContext ccContext = AppContextInfo.INSTANCE.getCCApplicationContext().getCCContext();
         Scheduler scheduler = null;
         try {
             scheduler = new Scheduler(ccContext.getClusterControllerInfo().getClientNetAddress(),
                     ccContext.getClusterControllerInfo().getClientNetPort());
         } catch (HyracksException e) {
-            throw new IllegalStateException("Cannot obtain hdfs scheduler");
+            throw new RuntimeDataException(ErrorCode.UTIL_HDFS_UTILS_CANNOT_OBTAIN_HDFS_SCHEDULER);
         }
         return scheduler;
     }
 
-    public static IndexingScheduler initializeIndexingHDFSScheduler() {
+    public static IndexingScheduler initializeIndexingHDFSScheduler() throws HyracksDataException {
         ICCContext ccContext = AppContextInfo.INSTANCE.getCCApplicationContext().getCCContext();
         IndexingScheduler scheduler = null;
         try {
             scheduler = new IndexingScheduler(ccContext.getClusterControllerInfo().getClientNetAddress(),
                     ccContext.getClusterControllerInfo().getClientNetPort());
         } catch (HyracksException e) {
-            throw new IllegalStateException("Cannot obtain hdfs scheduler");
+            throw new RuntimeDataException(ErrorCode.UTIL_HDFS_UTILS_CANNOT_OBTAIN_HDFS_SCHEDULER);
         }
         return scheduler;
     }
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/LocalFileSystemUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/LocalFileSystemUtils.java
index 16dd1e9..f6046ef 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/LocalFileSystemUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/LocalFileSystemUtils.java
@@ -29,7 +29,8 @@
 import java.util.LinkedList;
 import java.util.regex.Pattern;
 
-import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 
 public class LocalFileSystemUtils {
 
@@ -37,7 +38,8 @@
             final LinkedList<Path> dirs) throws IOException {
         final Path path = root.toPath();
         if (!Files.exists(path)) {
-            throw new HyracksDataException(path + ": path not found");
+            throw new RuntimeDataException(ErrorCode.UTIL_LOCAL_FILE_SYSTEM_UTILS_PATH_NOT_FOUND,
+                    path.toString());
         }
         if (!Files.isDirectory(path)) {
             validateAndAdd(path, expression, files);
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/NodeResolver.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/NodeResolver.java
index 52c2850..222d49d 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/NodeResolver.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/NodeResolver.java
@@ -28,6 +28,7 @@
 import java.util.Set;
 
 import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.external.api.INodeResolver;
 import org.apache.asterix.runtime.util.RuntimeUtils;
 
@@ -61,21 +62,20 @@
                     if (ncs.contains(value)) {
                         return value;
                     } else {
-                        throw new AsterixException("address passed: '" + value
-                                + "' couldn't be resolved to an ip address and is not an NC id. Existing NCs are "
-                                + ncs.toString(), uhe);
+                        throw new AsterixException(ErrorCode.NODE_RESOLVER_COULDNT_RESOLVE_ADDRESS, uhe, value,
+                                ncs.toString());
                     }
                 }
 
             }
             Set<String> nodeControllers = ncMap.get(ipAddress);
             if (nodeControllers == null || nodeControllers.isEmpty()) {
-                throw new AsterixException(" No node controllers found at the address: " + value);
+                throw new AsterixException(ErrorCode.NODE_RESOLVER_NO_NODE_CONTROLLERS, value);
             }
             String chosenNCId = nodeControllers.toArray(new String[] {})[random.nextInt(nodeControllers.size())];
             return chosenNCId;
         } catch (UnknownHostException e) {
-            throw new AsterixException("Unable to resolve hostname '" + value + "' to an IP address");
+            throw new AsterixException(ErrorCode.NODE_RESOLVER_UNABLE_RESOLVE_HOST, value);
         } catch (AsterixException ae) {
             throw ae;
         } catch (Exception e) {
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AddHashTagsFunction.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AddHashTagsFunction.java
index db717e6..96a40fb 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AddHashTagsFunction.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AddHashTagsFunction.java
@@ -34,7 +34,7 @@
     private JPoint location = null;
 
     @Override
-    public void initialize(IFunctionHelper functionHelper) {
+    public void initialize(IFunctionHelper functionHelper) throws Exception {
         list = new JUnorderedList(functionHelper.getObject(JTypeTag.STRING));
         location = new JPoint(0, 0);
     }
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AddHashTagsInPlaceFunction.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AddHashTagsInPlaceFunction.java
index b8f9165..57c8f1d 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AddHashTagsInPlaceFunction.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AddHashTagsInPlaceFunction.java
@@ -31,7 +31,7 @@
     private JUnorderedList list = null;
 
     @Override
-    public void initialize(IFunctionHelper functionHelper) {
+    public void initialize(IFunctionHelper functionHelper) throws Exception {
         list = new JUnorderedList(functionHelper.getObject(JTypeTag.STRING));
     }
 
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AllTypesFunction.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AllTypesFunction.java
index 8f65bee..aad83dd 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AllTypesFunction.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/AllTypesFunction.java
@@ -44,7 +44,7 @@
     private JOrderedList newFieldList;
 
     @Override
-    public void initialize(IFunctionHelper functionHelper) {
+    public void initialize(IFunctionHelper functionHelper) throws Exception {
         newFieldList = new JOrderedList(functionHelper.getObject(JTypeTag.INT));
     }
 
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
index adffe1e..40523ab 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
@@ -1744,7 +1744,7 @@
     }
 
     @Override
-    public void parse(IRawRecord<? extends char[]> record, DataOutput out) throws IOException {
+    public void parse(IRawRecord<? extends char[]> record, DataOutput out) throws HyracksDataException {
         try {
             resetPools();
             if (oldFormat) {
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ParseTweetFunction.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ParseTweetFunction.java
index b9c736a..7167ac9 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ParseTweetFunction.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ParseTweetFunction.java
@@ -24,13 +24,14 @@
 import org.apache.asterix.external.api.IExternalScalarFunction;
 import org.apache.asterix.external.api.IFunctionHelper;
 import org.apache.asterix.external.library.java.JTypeTag;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 public class ParseTweetFunction implements IExternalScalarFunction {
 
     private JUnorderedList list = null;
 
     @Override
-    public void initialize(IFunctionHelper functionHelper) {
+    public void initialize(IFunctionHelper functionHelper) throws Exception {
         list = new JUnorderedList(functionHelper.getObject(JTypeTag.STRING));
     }
 
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/parser/TestRecordWithPKParser.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/parser/TestRecordWithPKParser.java
index fd617bd..21a1430 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/parser/TestRecordWithPKParser.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/parser/TestRecordWithPKParser.java
@@ -25,6 +25,7 @@
 import org.apache.asterix.external.api.IRecordDataParser;
 import org.apache.asterix.external.api.IRecordWithPKDataParser;
 import org.apache.asterix.external.input.record.RecordWithPK;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
 
 public class TestRecordWithPKParser<T> implements IRecordWithPKDataParser<RecordWithPK<T>> {
@@ -36,13 +37,14 @@
     }
 
     @Override
-    public void parse(final IRawRecord<? extends RecordWithPK<T>> record, final DataOutput out) throws IOException {
+    public void parse(final IRawRecord<? extends RecordWithPK<T>> record, final DataOutput out) throws
+            HyracksDataException {
         recordParser.parse(record.get().getRecord(), out);
     }
 
     @Override
     public void appendKeys(final ArrayTupleBuilder tb, final IRawRecord<? extends RecordWithPK<T>> record)
-            throws IOException {
+            throws HyracksDataException {
         record.get().appendPrimaryKeyToTuple(tb);
     }
 
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
index b3cf694..cf57dfe 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
@@ -83,7 +83,7 @@
                 parseList((ListConstructor) expr, serialized);
                 break;
             default:
-                throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.ERROR_PARSE_ERROR,
+                throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
                         NOT_ALLOWED_EXPRESSIONS_ERROR_MESSAGE, new Serializable[] { Expression.Kind.LITERAL_EXPRESSION
                                 .toString(), Expression.Kind.RECORD_CONSTRUCTOR_EXPRESSION.toString(),
                                 Expression.Kind.LIST_CONSTRUCTOR_EXPRESSION.toString() });
@@ -129,13 +129,13 @@
 
     public static Literal exprToStringLiteral(Expression expr) throws HyracksDataException {
         if (expr.getKind() != Expression.Kind.LITERAL_EXPRESSION) {
-            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.ERROR_PARSE_ERROR,
+            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
                     "Expected expression can only be of type %1$s", Expression.Kind.LITERAL_EXPRESSION);
         }
         LiteralExpr keyLiteralExpr = (LiteralExpr) expr;
         Literal keyLiteral = keyLiteralExpr.getValue();
         if (keyLiteral.getLiteralType() != Literal.Type.STRING) {
-            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.ERROR_PARSE_ERROR,
+            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
                     "Expected Literal can only be of type %1$s", Literal.Type.STRING);
         }
         return keyLiteral;
@@ -144,7 +144,7 @@
     private static void parseList(ListConstructor valueExpr, ArrayBackedValueStorage serialized)
             throws HyracksDataException {
         if (valueExpr.getType() != ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR) {
-            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.ERROR_PARSE_ERROR,
+            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
                     "JSON List can't be of type %1$s", valueExpr.getType());
         }
         ArrayBackedValueStorage serializedValue = new ArrayBackedValueStorage();
@@ -187,7 +187,7 @@
                 stringSerde.serialize(new AString((String) value.getValue()), serialized.getDataOutput());
                 break;
             default:
-                throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.ERROR_PARSE_ERROR,
+                throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
                         "Unknown Literal Type %1$s", value.getLiteralType());
         }
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/IncompatibleTypeException.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/IncompatibleTypeException.java
index 728cd0c..531d752 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/IncompatibleTypeException.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/IncompatibleTypeException.java
@@ -30,11 +30,11 @@
 
     // Incompatible input parameters, e.g., "1.0" > 1.0
     public IncompatibleTypeException(FunctionIdentifier fid, ATypeTag typeTagLeft, ATypeTag typeTagRight) {
-        super(ErrorCode.ERROR_COMPILATION_TYPE_INCOMPATIBLE, fid.getName(), typeTagLeft, typeTagRight);
+        super(ErrorCode.COMPILATION_TYPE_INCOMPATIBLE, fid.getName(), typeTagLeft, typeTagRight);
     }
 
     // Incompatible input parameters, e.g., "1.0" > 1.0
     public IncompatibleTypeException(String functionName, ATypeTag typeTagLeft, ATypeTag typeTagRight) {
-        super(ErrorCode.ERROR_COMPILATION_TYPE_INCOMPATIBLE, functionName, typeTagLeft, typeTagRight);
+        super(ErrorCode.COMPILATION_TYPE_INCOMPATIBLE, functionName, typeTagLeft, typeTagRight);
     }
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/InvalidExpressionException.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/InvalidExpressionException.java
index c381b7b..1745bca 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/InvalidExpressionException.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/InvalidExpressionException.java
@@ -34,14 +34,14 @@
 
     public InvalidExpressionException(FunctionIdentifier fid, int index, ILogicalExpression actualExpr,
             LogicalExpressionTag... exprKinds) {
-        super(ErrorCode.ERROR_COMPILATION_INVALID_EXPRESSION, fid.getName(), indexToPosition(index),
+        super(ErrorCode.COMPILATION_INVALID_EXPRESSION, fid.getName(), indexToPosition(index),
                 actualExpr.toString(),
                 toExpectedTypeString(exprKinds));
     }
 
     public InvalidExpressionException(String functionName, int index, ILogicalExpression actualExpr,
             LogicalExpressionTag... exprKinds) {
-        super(ErrorCode.ERROR_COMPILATION_INVALID_EXPRESSION, functionName, indexToPosition(index),
+        super(ErrorCode.COMPILATION_INVALID_EXPRESSION, functionName, indexToPosition(index),
                 actualExpr.toString(),
                 toExpectedTypeString(exprKinds));
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/TypeMismatchException.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/TypeMismatchException.java
index c0ab958..b9dd568 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/TypeMismatchException.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/TypeMismatchException.java
@@ -34,13 +34,13 @@
     // Parameter type mistmatch.
     public TypeMismatchException(FunctionIdentifier fid, Integer i, ATypeTag actualTypeTag,
             ATypeTag... expectedTypeTags) {
-        super(ErrorCode.ERROR_COMPILATION_TYPE_MISMATCH, fid.getName(), indexToPosition(i),
+        super(ErrorCode.COMPILATION_TYPE_MISMATCH, fid.getName(), indexToPosition(i),
                 toExpectedTypeString(expectedTypeTags), actualTypeTag);
     }
 
     // Parameter type mistmatch.
     public TypeMismatchException(String functionName, Integer i, ATypeTag actualTypeTag, ATypeTag... expectedTypeTags) {
-        super(ErrorCode.ERROR_COMPILATION_TYPE_MISMATCH, functionName, indexToPosition(i),
+        super(ErrorCode.COMPILATION_TYPE_MISMATCH, functionName, indexToPosition(i),
                 toExpectedTypeString(expectedTypeTags), actualTypeTag);
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedItemTypeException.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedItemTypeException.java
index d1288aa..740703c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedItemTypeException.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedItemTypeException.java
@@ -30,11 +30,11 @@
 
     // Unsupported item type.
     public UnsupportedItemTypeException(FunctionIdentifier fid, ATypeTag itemTypeTag) {
-        super(ErrorCode.ERROR_COMPILATION_TYPE_ITEM, fid.getName(), itemTypeTag);
+        super(ErrorCode.COMPILATION_TYPE_ITEM, fid.getName(), itemTypeTag);
     }
 
     // Unsupported item type.
     public UnsupportedItemTypeException(String functionName, ATypeTag itemTypeTag) {
-        super(ErrorCode.ERROR_COMPILATION_TYPE_ITEM, functionName, itemTypeTag);
+        super(ErrorCode.COMPILATION_TYPE_ITEM, functionName, itemTypeTag);
     }
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedTypeException.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedTypeException.java
index 42e234f..64f1c2f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedTypeException.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedTypeException.java
@@ -30,11 +30,11 @@
 
     // Unsupported input type.
     public UnsupportedTypeException(FunctionIdentifier fid, ATypeTag actualTypeTag) {
-        super(ErrorCode.ERROR_COMPILATION_TYPE_UNSUPPORTED, fid.getName(), actualTypeTag);
+        super(ErrorCode.COMPILATION_TYPE_UNSUPPORTED, fid.getName(), actualTypeTag);
     }
 
     // Unsupported input type.
     public UnsupportedTypeException(String funcName, ATypeTag actualTypeTag) {
-        super(ErrorCode.ERROR_COMPILATION_TYPE_UNSUPPORTED, funcName, actualTypeTag);
+        super(ErrorCode.COMPILATION_TYPE_UNSUPPORTED, funcName, actualTypeTag);
     }
 }
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 d18b4d1..e0deb5a 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
@@ -234,7 +234,7 @@
                         fieldPermutation[reqFnPos] = fnPos;
                         openFields[fnPos] = false;
                     } else {
-                        throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.ERROR_CASTING_FIELD,
+                        throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.CASTING_FIELD,
                                 "Field type %1$s can't be promoted to type %2$s", inputTypeTag, requiredTypeTag);
                     }
                 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
index 2b4cbe8..c91a4e3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
@@ -90,7 +90,7 @@
             if (pos >= 0) {
                 IAType resultFieldType = resultFieldTypes.get(pos);
                 if (resultFieldType.getTypeTag() != fieldTypes[i].getTypeTag()) {
-                    throw new CompilationException(ErrorCode.ERROR_COMPILATION_DUPLICATE_FIELD_NAME, fieldNames[i]);
+                    throw new CompilationException(ErrorCode.COMPILATION_DUPLICATE_FIELD_NAME, fieldNames[i]);
                 }
                 // Assuming fieldTypes[i].getTypeTag() = resultFieldType.getTypeTag()
                 if (fieldTypes[i].getTypeTag() == ATypeTag.RECORD) {
@@ -118,7 +118,7 @@
 
     private IAType mergedNestedType(String fieldName, IAType fieldType1, IAType fieldType0) throws AlgebricksException {
         if (fieldType1.getTypeTag() != ATypeTag.RECORD || fieldType0.getTypeTag() != ATypeTag.RECORD) {
-            throw new CompilationException(ErrorCode.ERROR_COMPILATION_DUPLICATE_FIELD_NAME, fieldName);
+            throw new CompilationException(ErrorCode.COMPILATION_DUPLICATE_FIELD_NAME, fieldName);
         }
 
         ARecordType resultType = (ARecordType) fieldType0;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SwitchCaseComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SwitchCaseComputer.java
index c112bf2..fa2bf5b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SwitchCaseComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SwitchCaseComputer.java
@@ -47,7 +47,7 @@
 
         int argNumber = fce.getArguments().size();
         if (argNumber < 3) {
-            throw new CompilationException(ErrorCode.ERROR_COMPILATION_INVALID_PARAMETER_NUMBER, funcName, argNumber);
+            throw new CompilationException(ErrorCode.COMPILATION_INVALID_PARAMETER_NUMBER, funcName, argNumber);
         }
         int argSize = fce.getArguments().size();
         List<IAType> types = new ArrayList<>();
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 515ea67..9212949 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
@@ -660,7 +660,7 @@
         ATypeTag sourceTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[typeTagPosition]];
 
         if (sourceTypeTag == null) {
-            throw new RuntimeDataException(ErrorCode.ERROR_INVALID_FORMAT, name, argIndex);
+            throw new RuntimeDataException(ErrorCode.INVALID_FORMAT, name, argIndex);
         }
         switch (sourceTypeTag) {
             case INT64:
@@ -682,7 +682,7 @@
                 value = (int) DoublePointable.getDouble(bytes, offset);
                 break;
             default:
-                throw new RuntimeDataException(ErrorCode.ERROR_TYPE_MISMATCH, name, argIndex, sourceTypeTag,
+                throw new RuntimeDataException(ErrorCode.TYPE_MISMATCH, name, argIndex, sourceTypeTag,
                         ATypeTag.INT8, ATypeTag.INT16, ATypeTag.INT32, ATypeTag.INT64, ATypeTag.FLOAT, ATypeTag.DOUBLE);
 
         }
@@ -701,7 +701,7 @@
         long value;
         ATypeTag sourceTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[typeTagPosition]];
         if (sourceTypeTag == null) {
-            throw new RuntimeDataException(ErrorCode.ERROR_INVALID_FORMAT, name, argIndex);
+            throw new RuntimeDataException(ErrorCode.INVALID_FORMAT, name, argIndex);
         }
         switch (sourceTypeTag) {
             case INT64:
@@ -723,7 +723,7 @@
                 value = (long) DoublePointable.getDouble(bytes, offset);
                 break;
             default:
-                throw new RuntimeDataException(ErrorCode.ERROR_TYPE_MISMATCH, name, argIndex, sourceTypeTag,
+                throw new RuntimeDataException(ErrorCode.TYPE_MISMATCH, name, argIndex, sourceTypeTag,
                         ATypeTag.INT8, ATypeTag.INT16, ATypeTag.INT32, ATypeTag.INT64, ATypeTag.FLOAT, ATypeTag.DOUBLE);
         }
 
@@ -743,7 +743,7 @@
         double value;
         ATypeTag sourceTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[typeTagPosition]];
         if (sourceTypeTag == null) {
-            throw new RuntimeDataException(ErrorCode.ERROR_INVALID_FORMAT, name, argIndex);
+            throw new RuntimeDataException(ErrorCode.INVALID_FORMAT, name, argIndex);
         }
         switch (sourceTypeTag) {
             case INT64:
@@ -765,7 +765,7 @@
                 value = DoublePointable.getDouble(bytes, offset);
                 break;
             default:
-                throw new RuntimeDataException(ErrorCode.ERROR_TYPE_MISMATCH, name, argIndex, sourceTypeTag,
+                throw new RuntimeDataException(ErrorCode.TYPE_MISMATCH, name, argIndex, sourceTypeTag,
                         ATypeTag.INT8, ATypeTag.INT16, ATypeTag.INT32, ATypeTag.INT64, ATypeTag.FLOAT, ATypeTag.DOUBLE);
         }
 
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java
index 5a26b5e..164f369 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java
@@ -75,7 +75,7 @@
                             boolean argResult = ABooleanSerializerDeserializer.getBoolean(argPtr.getByteArray(),
                                     argPtr.getStartOffset() + 1);
                             if (argResult) {
-                                throw new RuntimeDataException(ErrorCode.ERROR_INJECTED_FAILURE, getIdentifier());
+                                throw new RuntimeDataException(ErrorCode.INJECTED_FAILURE, getIdentifier());
                             }
                         }
 
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRepeatDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRepeatDescriptor.java
index bb9a263..fe864f4 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRepeatDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRepeatDescriptor.java
@@ -87,7 +87,7 @@
                                 offset);
                         // Checks repeatingTimes. It should be a non-negative value.
                         if (repeatingTimes < 0) {
-                            throw new RuntimeDataException(ErrorCode.ERROR_NEGATIVE_VALUE, getIdentifier(), 1,
+                            throw new RuntimeDataException(ErrorCode.NEGATIVE_VALUE, getIdentifier(), 1,
                                     repeatingTimes);
                         }
 
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java
index ec8e409..5a36942 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java
@@ -91,7 +91,7 @@
                         try {
                             UTF8StringPointable.substr(string, start, Integer.MAX_VALUE, builder, array);
                         } catch (StringIndexOutOfBoundsException e) {
-                            throw new RuntimeDataException(ErrorCode.ERROR_OUT_OF_BOUND, getIdentifier(), 1, start);
+                            throw new RuntimeDataException(ErrorCode.OUT_OF_BOUND, getIdentifier(), 1, start);
                         } catch (IOException e) {
                             throw new HyracksDataException(e);
                         }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java
index 184773b..caaa11a 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java
@@ -103,7 +103,7 @@
                         try {
                             UTF8StringPointable.substr(string, start, len, builder, array);
                         } catch (StringIndexOutOfBoundsException e) {
-                            throw new RuntimeDataException(ErrorCode.ERROR_OUT_OF_BOUND, getIdentifier(), 1,
+                            throw new RuntimeDataException(ErrorCode.OUT_OF_BOUND, getIdentifier(), 1,
                                     start + len - 1);
                         } catch (IOException e) {
                             throw new HyracksDataException(e);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
index 6b11353..5f2a730 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
@@ -240,7 +240,7 @@
                                     tempValReference.set(entry.getBuf(), entry.getOffset(), entry.getLength());
                                     // If value is not equal throw conflicting duplicate field, otherwise ignore
                                     if (!PointableHelper.byteArrayEqual(valuePointable, tempValReference)) {
-                                        throw new RuntimeDataException(ErrorCode.ERROR_DUPLICATE_FIELD_NAME,
+                                        throw new RuntimeDataException(ErrorCode.DUPLICATE_FIELD_NAME,
                                                 getIdentifier());
                                     }
                                 } else {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
index 2f33a4e..7a1e69f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
@@ -160,7 +160,7 @@
                                                 openFromParent, nestedLevel);
                                         foundMatch = true;
                                     } else {
-                                        throw new RuntimeDataException(ErrorCode.ERROR_DUPLICATE_FIELD_NAME,
+                                        throw new RuntimeDataException(ErrorCode.DUPLICATE_FIELD_NAME,
                                                 getIdentifier());
                                     }
                                 }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/IncompatibleTypeException.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/IncompatibleTypeException.java
index 0dad96c..3e5b311 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/IncompatibleTypeException.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/IncompatibleTypeException.java
@@ -28,14 +28,14 @@
 
     // Incompatible input parameters, e.g., "1.0" > 1.0
     public IncompatibleTypeException(FunctionIdentifier fid, byte typeTagLeft, byte typeTagRight) {
-        super(ErrorCode.ERROR_TYPE_INCOMPATIBLE, fid.getName(),
+        super(ErrorCode.TYPE_INCOMPATIBLE, fid.getName(),
                 EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(typeTagLeft),
                 EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(typeTagRight));
     }
 
     // Incompatible input parameters, e.g., "1.0" > 1.0
     public IncompatibleTypeException(String functionName, byte typeTagLeft, byte typeTagRight) {
-        super(ErrorCode.ERROR_TYPE_INCOMPATIBLE, functionName,
+        super(ErrorCode.TYPE_INCOMPATIBLE, functionName,
                 EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(typeTagLeft),
                 EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(typeTagRight));
     }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/InvalidDataFormatException.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/InvalidDataFormatException.java
index 0fdb1f0..acb0495 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/InvalidDataFormatException.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/InvalidDataFormatException.java
@@ -27,16 +27,16 @@
 public class InvalidDataFormatException extends RuntimeDataException {
 
     public InvalidDataFormatException(FunctionIdentifier fid, byte expectedTypeTag) {
-        super(ErrorCode.ERROR_INVALID_FORMAT, fid.getName(),
+        super(ErrorCode.INVALID_FORMAT, fid.getName(),
                 EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(expectedTypeTag));
     }
 
     public InvalidDataFormatException(FunctionIdentifier fid, String expectedType) {
-        super(ErrorCode.ERROR_INVALID_FORMAT, fid.getName(), expectedType);
+        super(ErrorCode.INVALID_FORMAT, fid.getName(), expectedType);
     }
 
     public InvalidDataFormatException(FunctionIdentifier fid, Throwable cause, byte expectedTypeTag) {
-        super(ErrorCode.ERROR_INVALID_FORMAT, fid.getName(), cause, expectedTypeTag);
+        super(ErrorCode.INVALID_FORMAT, fid.getName(), cause, expectedTypeTag);
         addSuppressed(cause);
     }
 
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/OverflowException.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/OverflowException.java
index 968a54f..3690236 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/OverflowException.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/OverflowException.java
@@ -27,12 +27,12 @@
 
     // Overflow.
     public OverflowException(FunctionIdentifier fid) {
-        super(ErrorCode.ERROR_OVERFLOW, fid.getName());
+        super(ErrorCode.OVERFLOW, fid.getName());
     }
 
     // Overflow.
     public OverflowException(String functionName) {
-        super(ErrorCode.ERROR_OVERFLOW, functionName);
+        super(ErrorCode.OVERFLOW, functionName);
     }
 
 }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/TypeMismatchException.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/TypeMismatchException.java
index 2a838a2..c061197 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/TypeMismatchException.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/TypeMismatchException.java
@@ -31,13 +31,13 @@
 
     // Parameter type mistmatch.
     public TypeMismatchException(FunctionIdentifier fid, Integer i, byte actualTypeTag, byte... expectedTypeTags) {
-        super(ErrorCode.ERROR_TYPE_MISMATCH, fid.getName(), indexToPosition(i), toExpectedTypeString(expectedTypeTags),
+        super(ErrorCode.TYPE_MISMATCH, fid.getName(), indexToPosition(i), toExpectedTypeString(expectedTypeTags),
                 EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
     }
 
     // Parameter type mistmatch.
     public TypeMismatchException(String functionName, Integer i, byte actualTypeTag, byte... expectedTypeTags) {
-        super(ErrorCode.ERROR_TYPE_MISMATCH, functionName, indexToPosition(i), toExpectedTypeString(expectedTypeTags),
+        super(ErrorCode.TYPE_MISMATCH, functionName, indexToPosition(i), toExpectedTypeString(expectedTypeTags),
                 EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
     }
 
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnderflowException.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnderflowException.java
index cb39ab2..6471cbd 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnderflowException.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnderflowException.java
@@ -27,12 +27,12 @@
 
     // Underflow.
     public UnderflowException(FunctionIdentifier fid) {
-        super(ErrorCode.ERROR_UNDERFLOW, fid.getName());
+        super(ErrorCode.UNDERFLOW, fid.getName());
     }
 
     // Underflow.
     public UnderflowException(String functionName) {
-        super(ErrorCode.ERROR_UNDERFLOW, functionName);
+        super(ErrorCode.UNDERFLOW, functionName);
     }
 
 }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnsupportedItemTypeException.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnsupportedItemTypeException.java
index 79d9266..f634649 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnsupportedItemTypeException.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnsupportedItemTypeException.java
@@ -28,11 +28,11 @@
 
     // Unsupported item type.
     public UnsupportedItemTypeException(FunctionIdentifier fid, byte itemTypeTag) {
-        super(ErrorCode.ERROR_TYPE_ITEM, fid.getName(), EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag));
+        super(ErrorCode.TYPE_ITEM, fid.getName(), EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag));
     }
 
     // Unsupported item type.
     public UnsupportedItemTypeException(String functionName, byte itemTypeTag) {
-        super(ErrorCode.ERROR_TYPE_ITEM, functionName, EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag));
+        super(ErrorCode.TYPE_ITEM, functionName, EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag));
     }
 }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnsupportedTypeException.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnsupportedTypeException.java
index 6279fbc..af86bd8 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnsupportedTypeException.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/UnsupportedTypeException.java
@@ -28,13 +28,13 @@
 
     // Unsupported input type.
     public UnsupportedTypeException(FunctionIdentifier fid, byte actualTypeTag) {
-        super(ErrorCode.ERROR_TYPE_UNSUPPORTED, fid.getName(),
+        super(ErrorCode.TYPE_UNSUPPORTED, fid.getName(),
                 EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
     }
 
     // Unsupported input type.
     public UnsupportedTypeException(String funcName, byte actualTypeTag) {
-        super(ErrorCode.ERROR_TYPE_UNSUPPORTED, funcName,
+        super(ErrorCode.TYPE_UNSUPPORTED, funcName,
                 EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
     }
 }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
index 3f8a9a8..1d4dd89 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
@@ -101,7 +101,7 @@
 
                             if (typeTag != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
                                     && typeTag != ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
-                                throw new RuntimeDataException(ErrorCode.ERROR_COERCION, getIdentifier());
+                                throw new RuntimeDataException(ErrorCode.COERCION, getIdentifier());
                             }
                             if (typeTag == ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
                                 numItemsMax = AOrderedListSerializerDeserializer.getNumberOfItems(serList, offset);