http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-client/src/main/java/org/apache/tajo/client/v2/ClientDelegate.java
----------------------------------------------------------------------
diff --git 
a/tajo-client/src/main/java/org/apache/tajo/client/v2/ClientDelegate.java 
b/tajo-client/src/main/java/org/apache/tajo/client/v2/ClientDelegate.java
index 8dce7c4..80c0172 100644
--- a/tajo-client/src/main/java/org/apache/tajo/client/v2/ClientDelegate.java
+++ b/tajo-client/src/main/java/org/apache/tajo/client/v2/ClientDelegate.java
@@ -18,7 +18,8 @@
 
 package org.apache.tajo.client.v2;
 
-import org.apache.tajo.catalog.exception.UndefinedDatabaseException;
+import org.apache.tajo.exception.QueryFailedException;
+import org.apache.tajo.exception.UndefinedDatabaseException;
 import org.apache.tajo.exception.TajoException;
 
 import java.io.Closeable;
@@ -31,7 +32,7 @@ public interface ClientDelegate extends Closeable {
 
   int executeUpdate(String sql) throws TajoException;
 
-  ResultSet executeSQL(String sql) throws TajoException;
+  ResultSet executeSQL(String sql) throws TajoException, QueryFailedException;
 
   QueryFuture executeSQLAsync(String sql) throws TajoException;
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-client/src/main/java/org/apache/tajo/client/v2/LegacyClientDelegate.java
----------------------------------------------------------------------
diff --git 
a/tajo-client/src/main/java/org/apache/tajo/client/v2/LegacyClientDelegate.java 
b/tajo-client/src/main/java/org/apache/tajo/client/v2/LegacyClientDelegate.java
index a17311b..697c1ac 100644
--- 
a/tajo-client/src/main/java/org/apache/tajo/client/v2/LegacyClientDelegate.java
+++ 
b/tajo-client/src/main/java/org/apache/tajo/client/v2/LegacyClientDelegate.java
@@ -18,17 +18,17 @@
 
 package org.apache.tajo.client.v2;
 
-import com.google.common.base.Optional;
 import com.google.common.util.concurrent.AbstractFuture;
 import org.apache.tajo.QueryId;
 import org.apache.tajo.TajoProtos;
 import org.apache.tajo.annotation.ThreadSafe;
 import org.apache.tajo.auth.UserRoleInfo;
-import org.apache.tajo.catalog.exception.UndefinedDatabaseException;
-import org.apache.tajo.client.*;
+import org.apache.tajo.client.DummyServiceTracker;
+import org.apache.tajo.client.QueryClientImpl;
+import org.apache.tajo.client.SessionConnection;
+import org.apache.tajo.client.TajoClientUtil;
 import org.apache.tajo.conf.TajoConf;
-import org.apache.tajo.exception.TajoException;
-import org.apache.tajo.exception.UnimplementedException;
+import org.apache.tajo.exception.*;
 import org.apache.tajo.ipc.ClientProtos;
 import org.apache.tajo.ipc.ClientProtos.GetQueryStatusResponse;
 import org.apache.tajo.service.ServiceTracker;
@@ -72,10 +72,20 @@ public class LegacyClientDelegate extends SessionConnection 
implements ClientDel
   }
 
   @Override
-  public ResultSet executeSQL(String sql) throws TajoException {
+  public ResultSet executeSQL(String sql) throws TajoException, 
QueryFailedException, QueryKilledException {
     try {
       return executeSQLAsync(sql).get();
-    } catch (InterruptedException | ExecutionException e) {
+
+    } catch (ExecutionException e) {
+
+      if (e.getCause() instanceof TajoException) {
+        throw (TajoException) e.getCause();
+      } else if (e.getCause() instanceof TajoRuntimeException) {
+        throw new TajoException((TajoRuntimeException)e.getCause());
+      } else {
+        throw new TajoInternalError(e);
+      }
+    } catch (InterruptedException e) {
       throw new RuntimeException(e);
     }
   }
@@ -83,7 +93,7 @@ public class LegacyClientDelegate extends SessionConnection 
implements ClientDel
   @Override
   public QueryFuture executeSQLAsync(String sql) throws TajoException {
     ClientProtos.SubmitQueryResponse response = queryClient.executeQuery(sql);
-    ClientExceptionUtil.throwIfError(response.getState());
+    ExceptionUtil.throwIfError(response.getState());
 
     QueryId queryId = new QueryId(response.getQueryId());
 
@@ -270,7 +280,11 @@ public class LegacyClientDelegate extends 
SessionConnection implements ClientDel
 
     @Override
     public boolean isKilled() {
-      return queryClient.getQueryStatus(queryId).getState() == 
TajoProtos.QueryState.QUERY_KILLED;
+      try {
+        return queryClient.getQueryStatus(queryId).getState() == 
TajoProtos.QueryState.QUERY_KILLED;
+      } catch (QueryNotFoundException e) {
+        throw new TajoInternalError(e);
+      }
     }
 
     @Override
@@ -295,7 +309,11 @@ public class LegacyClientDelegate extends 
SessionConnection implements ClientDel
 
     @Override
     public void kill() {
-      queryClient.killQuery(queryId).getState();
+      try {
+        queryClient.killQuery(queryId).getState();
+      } catch (QueryNotFoundException e) {
+        throw new TajoInternalError(e);
+      }
     }
 
     @Override
@@ -337,7 +355,8 @@ public class LegacyClientDelegate extends SessionConnection 
implements ClientDel
     }
 
     GetQueryStatusResponse waitCompletion() {
-      GetQueryStatusResponse response = queryClient.getRawQueryStatus(queryId);
+      GetQueryStatusResponse response;
+      response = queryClient.getRawQueryStatus(queryId);
       ensureOk(response.getState());
       updateState(response);
 
@@ -367,13 +386,26 @@ public class LegacyClientDelegate extends 
SessionConnection implements ClientDel
 
       if (finalResponse.getQueryState() == 
TajoProtos.QueryState.QUERY_SUCCEEDED) {
         if (finalResponse.hasHasResult()) {
-          set(queryClient.getQueryResult(queryId));
+          try {
+            set(queryClient.getQueryResult(queryId));
+          } catch (QueryNotFoundException e) {
+            setException(e);
+            return;
+          }
         } else { // when update
           set(TajoClientUtil.NULL_RESULT_SET);
         }
+
+      } else if (finalResponse.getQueryState() == 
TajoProtos.QueryState.QUERY_KILLED) {
+        setException(new QueryKilledException());
+
       } else {
-        cancel(false); // failed
-        set(TajoClientUtil.NULL_RESULT_SET);
+        if (finalResponse.hasErrorMessage()) {
+          setException(new 
QueryFailedException(finalResponse.getErrorMessage()));
+        } else {
+          setException(new QueryFailedException(
+              "internal error. See master and worker logs in 
${tajo-install-dir}/logs for the cause of this error"));
+        }
       }
     }
   }
@@ -402,52 +434,52 @@ public class LegacyClientDelegate extends 
SessionConnection implements ClientDel
 
     @Override
     public InetSocketAddress getResourceTrackerAddress() throws 
ServiceTrackerException {
-      throw new UnimplementedException();
+      throw new NotImplementedException();
     }
 
     @Override
     public InetSocketAddress getCatalogAddress() throws 
ServiceTrackerException {
-      throw new UnimplementedException();
+      throw new NotImplementedException();
     }
 
     @Override
     public InetSocketAddress getMasterHttpInfo() throws 
ServiceTrackerException {
-      throw new UnimplementedException();
+      throw new NotImplementedException();
     }
 
     @Override
     public int getState(String masterName, TajoConf conf) throws 
ServiceTrackerException {
-      throw new UnimplementedException();
+      throw new NotImplementedException();
     }
 
     @Override
     public int formatHA(TajoConf conf) throws ServiceTrackerException {
-      throw new UnimplementedException();
+      throw new NotImplementedException();
     }
 
     @Override
     public List<String> getMasters(TajoConf conf) throws 
ServiceTrackerException {
-      throw new UnimplementedException();
+      throw new NotImplementedException();
     }
 
     @Override
     public void register() throws IOException {
-      throw new UnimplementedException();
+      throw new NotImplementedException();
     }
 
     @Override
     public void delete() throws IOException {
-      throw new UnimplementedException();
+      throw new NotImplementedException();
     }
 
     @Override
     public boolean isActiveMaster() {
-      throw new UnimplementedException();
+      throw new NotImplementedException();
     }
 
     @Override
     public List<TajoMasterInfo> getMasters() throws IOException {
-      throw new UnimplementedException();
+      throw new NotImplementedException();
     }
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-client/src/main/java/org/apache/tajo/client/v2/TajoClient.java
----------------------------------------------------------------------
diff --git 
a/tajo-client/src/main/java/org/apache/tajo/client/v2/TajoClient.java 
b/tajo-client/src/main/java/org/apache/tajo/client/v2/TajoClient.java
index 08a921d..f9401cb 100644
--- a/tajo-client/src/main/java/org/apache/tajo/client/v2/TajoClient.java
+++ b/tajo-client/src/main/java/org/apache/tajo/client/v2/TajoClient.java
@@ -18,7 +18,8 @@
 
 package org.apache.tajo.client.v2;
 
-import org.apache.tajo.catalog.exception.UndefinedDatabaseException;
+import org.apache.tajo.exception.QueryFailedException;
+import org.apache.tajo.exception.UndefinedDatabaseException;
 import org.apache.tajo.client.v2.exception.ClientUnableToConnectException;
 import org.apache.tajo.exception.TajoException;
 
@@ -114,7 +115,7 @@ public class TajoClient implements Closeable {
    * @return QueryHandler
    * @throws TajoException
    */
-  public ResultSet executeQuery(String sql) throws TajoException {
+  public ResultSet executeQuery(String sql) throws TajoException, 
QueryFailedException {
     return delegate.executeSQL(sql);
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-client/src/main/java/org/apache/tajo/client/v2/exception/ClientUnableToConnectException.java
----------------------------------------------------------------------
diff --git 
a/tajo-client/src/main/java/org/apache/tajo/client/v2/exception/ClientUnableToConnectException.java
 
b/tajo-client/src/main/java/org/apache/tajo/client/v2/exception/ClientUnableToConnectException.java
index e567d7d..dfa9c01 100644
--- 
a/tajo-client/src/main/java/org/apache/tajo/client/v2/exception/ClientUnableToConnectException.java
+++ 
b/tajo-client/src/main/java/org/apache/tajo/client/v2/exception/ClientUnableToConnectException.java
@@ -22,7 +22,7 @@ import org.apache.tajo.error.Errors;
 import org.apache.tajo.exception.TajoException;
 
 public class ClientUnableToConnectException extends TajoException {
-  public ClientUnableToConnectException() {
+  public ClientUnableToConnectException(String address) {
     super(Errors.ResultCode.CLIENT_UNABLE_TO_ESTABLISH_CONNECTION);
   }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-client/src/main/java/org/apache/tajo/jdbc/WaitingResultSet.java
----------------------------------------------------------------------
diff --git 
a/tajo-client/src/main/java/org/apache/tajo/jdbc/WaitingResultSet.java 
b/tajo-client/src/main/java/org/apache/tajo/jdbc/WaitingResultSet.java
index b9f8df5..68cc2fc 100644
--- a/tajo-client/src/main/java/org/apache/tajo/jdbc/WaitingResultSet.java
+++ b/tajo-client/src/main/java/org/apache/tajo/jdbc/WaitingResultSet.java
@@ -27,6 +27,8 @@ import org.apache.tajo.catalog.TableDesc;
 import org.apache.tajo.client.QueryClient;
 import org.apache.tajo.client.QueryStatus;
 import org.apache.tajo.client.TajoClientUtil;
+import org.apache.tajo.exception.SQLExceptionUtil;
+import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.ipc.ClientProtos;
 
 import java.sql.SQLException;
@@ -66,6 +68,8 @@ public class WaitingResultSet extends FetchResultSet {
       return tableDesc.getLogicalSchema();
     } catch (ServiceException e) {
       throw new SQLException(e);
+    } catch (TajoException e) {
+      throw SQLExceptionUtil.toSQLException(e);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-client/src/main/java/org/apache/tajo/storage/RowStoreUtil.java
----------------------------------------------------------------------
diff --git 
a/tajo-client/src/main/java/org/apache/tajo/storage/RowStoreUtil.java 
b/tajo-client/src/main/java/org/apache/tajo/storage/RowStoreUtil.java
index 87282a0..13b0201 100644
--- a/tajo-client/src/main/java/org/apache/tajo/storage/RowStoreUtil.java
+++ b/tajo-client/src/main/java/org/apache/tajo/storage/RowStoreUtil.java
@@ -23,8 +23,7 @@ import org.apache.tajo.catalog.Schema;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.datum.DatumFactory;
 import org.apache.tajo.datum.IntervalDatum;
-import org.apache.tajo.datum.ProtobufDatum;
-import org.apache.tajo.exception.UnknownDataTypeException;
+import org.apache.tajo.exception.UnsupportedDataTypeException;
 import org.apache.tajo.exception.UnsupportedException;
 import org.apache.tajo.exception.ValueTooLongForTypeCharactersException;
 import org.apache.tajo.util.BitArray;
@@ -158,7 +157,7 @@ public class RowStoreUtil {
             // TODO - to be implemented
             throw new UnsupportedException(type.getType().name());
           default:
-            throw new RuntimeException(new 
UnknownDataTypeException(type.getType().name()));
+            throw new RuntimeException(new 
UnsupportedDataTypeException(type.getType().name()));
         }
       }
       return tuple;
@@ -259,7 +258,7 @@ public class RowStoreUtil {
             bb.put(tuple.getBytes(i));
             break;
           default:
-            throw new RuntimeException(new 
UnknownDataTypeException(col.getDataType().getType().name()));
+            throw new RuntimeException(new 
UnsupportedDataTypeException(col.getDataType().getType().name()));
         }
       }
 
@@ -320,7 +319,7 @@ public class RowStoreUtil {
             size += tuple.getBytes(i).length;
             break;
           default:
-            throw new RuntimeException(new 
UnknownDataTypeException(col.getDataType().getType().name()));
+            throw new RuntimeException(new 
UnsupportedDataTypeException(col.getDataType().getType().name()));
         }
       }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousFunctionException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousFunctionException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousFunctionException.java
new file mode 100644
index 0000000..7945963
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousFunctionException.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class AmbiguousFunctionException extends TajoException {
+
+  public AmbiguousFunctionException(ReturnState state) {
+    super(state);
+  }
+
+  public AmbiguousFunctionException(String signature) {
+    super(Errors.ResultCode.AMBIGUOUS_FUNCTION, signature);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousPartitionDirectoryExistException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousPartitionDirectoryExistException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousPartitionDirectoryExistException.java
new file mode 100644
index 0000000..eb632e8
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousPartitionDirectoryExistException.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+
+import org.apache.tajo.error.Errors.ResultCode;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class AmbiguousPartitionDirectoryExistException extends TajoException {
+       private static final long serialVersionUID = 277182608283894931L;
+
+  public AmbiguousPartitionDirectoryExistException(ReturnState state) {
+    super(state);
+  }
+
+       public AmbiguousPartitionDirectoryExistException(String columnName) {
+               super(ResultCode.AMBIGUOUS_PARTITION_DIRECTORY, columnName);
+       }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousTableException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousTableException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousTableException.java
new file mode 100644
index 0000000..136a07f
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousTableException.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class AmbiguousTableException extends TajoException {
+
+  public AmbiguousTableException(ReturnState state) {
+    super(state);
+  }
+
+  public AmbiguousTableException(String tableName) {
+    super(Errors.ResultCode.AMBIGUOUS_TABLE, tableName);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/CatalogUpgradeRequiredException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/CatalogUpgradeRequiredException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/CatalogUpgradeRequiredException.java
new file mode 100644
index 0000000..901e2dd
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/CatalogUpgradeRequiredException.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors.ResultCode;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class CatalogUpgradeRequiredException extends TajoException {
+
+  public CatalogUpgradeRequiredException() {
+    super(ResultCode.CAT_UPGRADE_REQUIRED);
+  }
+
+  public CatalogUpgradeRequiredException(ReturnState e) {
+    super(e);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/DataTypeMismatchException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/DataTypeMismatchException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/DataTypeMismatchException.java
new file mode 100644
index 0000000..3a41c7e
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/DataTypeMismatchException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors.ResultCode;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class DataTypeMismatchException extends TajoException {
+
+  public DataTypeMismatchException(ReturnState e) {
+    super(e);
+  }
+
+  public DataTypeMismatchException(String columnName, String columnType,
+                                   String expression, String 
expressionDataType) {
+    super(ResultCode.DATATYPE_MISMATCH, columnName, columnType, expression, 
expressionDataType);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/DefaultTajoException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/DefaultTajoException.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/DefaultTajoException.java
new file mode 100644
index 0000000..8bce9e4
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/DefaultTajoException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors.ResultCode;
+
+/**
+ * Abstracted exception or error interface. TajoException and
+ * TajoRuntimeException always have a ResultCode and a message.
+ * This interface helps routines access both TajoException and
+ * TajoRuntimeException in a common way.
+ */
+public interface DefaultTajoException {
+
+  ResultCode getErrorCode();
+
+  String getMessage();
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateColumnException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateColumnException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateColumnException.java
new file mode 100644
index 0000000..623a18b
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateColumnException.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class DuplicateColumnException extends TajoException {
+       private static final long serialVersionUID = 6766228091940775275L;
+
+  public DuplicateColumnException(ReturnState state) {
+    super(state);
+  }
+
+       public DuplicateColumnException(String columnName) {
+               super(Errors.ResultCode.DUPLICATE_COLUMN, columnName);
+       }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateDatabaseException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateDatabaseException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateDatabaseException.java
new file mode 100644
index 0000000..2ead97d
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateDatabaseException.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class DuplicateDatabaseException extends TajoException {
+
+  public DuplicateDatabaseException(ReturnState state) {
+    super(state);
+  }
+       public DuplicateDatabaseException(String dbName) {
+               super(Errors.ResultCode.DUPLICATE_DATABASE, dbName);
+       }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateFunctionException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateFunctionException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateFunctionException.java
new file mode 100644
index 0000000..cc86bbb
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateFunctionException.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class DuplicateFunctionException extends TajoException {
+  private static final long serialVersionUID = 3224521585413794703L;
+
+  public DuplicateFunctionException(ReturnState state) {
+    super(state);
+  }
+
+  public DuplicateFunctionException(String signature) {
+    super(Errors.ResultCode.DUPLICATE_FUNCTION, signature);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateIndexException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateIndexException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateIndexException.java
new file mode 100644
index 0000000..19239e4
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateIndexException.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class DuplicateIndexException extends TajoException {
+  private static final long serialVersionUID = 3705839985189534673L;
+
+  public DuplicateIndexException(ReturnState state) {
+    super(state);
+  }
+
+  public DuplicateIndexException(String indexName) {
+    super(Errors.ResultCode.DUPLICATE_INDEX, indexName);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/DuplicatePartitionException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/DuplicatePartitionException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicatePartitionException.java
new file mode 100644
index 0000000..b1ca2ee
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicatePartitionException.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class DuplicatePartitionException extends TajoException {
+  private static final long serialVersionUID = 277182608283894930L;
+
+  public DuplicatePartitionException(ReturnState state) {
+    super(state);
+  }
+
+  public DuplicatePartitionException(String partitionName) {
+    super(Errors.ResultCode.DUPLICATE_PARTITION, partitionName);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateTableException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateTableException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateTableException.java
new file mode 100644
index 0000000..873b927
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateTableException.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class DuplicateTableException extends TajoException {
+       private static final long serialVersionUID = -641623770742392865L;
+
+  public DuplicateTableException(ReturnState state) {
+    super(state);
+  }
+
+  public DuplicateTableException(String relName) {
+    super(Errors.ResultCode.DUPLICATE_TABLE, relName);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateTablespaceException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateTablespaceException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateTablespaceException.java
new file mode 100644
index 0000000..e3ad86f
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/DuplicateTablespaceException.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class DuplicateTablespaceException extends TajoException {
+
+  public DuplicateTablespaceException(ReturnState state) {
+    super(state);
+  }
+
+       public DuplicateTablespaceException(String spaceName) {
+               super(Errors.ResultCode.DUPLICATE_TABLESPACE, spaceName);
+       }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/ErrorMessages.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/ErrorMessages.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/ErrorMessages.java
index 3b646e1..ad5776c 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/ErrorMessages.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/ErrorMessages.java
@@ -42,7 +42,9 @@ public class ErrorMessages {
     ADD_MESSAGE(INVALID_RPC_CALL, "invalid RPC Call: %s", 1);
 
     // Query Management and Scheduler
-    ADD_MESSAGE(NO_SUCH_QUERYID, "query %s does not exist", 1);
+    ADD_MESSAGE(QUERY_FAILED, "query has been failed due to %s", 1);
+    ADD_MESSAGE(QUERY_KILLED, "query has been killed");
+    ADD_MESSAGE(QUERY_NOT_FOUND, "query %s does not exist", 1);
     ADD_MESSAGE(NO_DATA, "no data for %s due to query failure or error", 1);
     ADD_MESSAGE(INCOMPLETE_QUERY, "query %s is stilling running", 1);
 
@@ -52,9 +54,9 @@ public class ErrorMessages {
     ADD_MESSAGE(INVALID_SESSION_VARIABLE, "invalid session variable '%s': %s", 
2);
 
 
-
+    // Syntax Error or Access Rule Violation
     ADD_MESSAGE(SYNTAX_ERROR, "%s", 1);
-    ADD_MESSAGE(INSUFFICIENT_PRIVILEGE, "Insufficient privilege to %s");
+    ADD_MESSAGE(INSUFFICIENT_PRIVILEGE, "Insufficient privilege to %s", 1);
     ADD_MESSAGE(INVALID_NAME, "Invalid name '%s'");
 
     ADD_MESSAGE(UNDEFINED_TABLESPACE, "tablespace '%s' does not exist", 1);
@@ -63,8 +65,9 @@ public class ErrorMessages {
     ADD_MESSAGE(UNDEFINED_TABLE, "relation '%s' does not exist", 1);
     ADD_MESSAGE(UNDEFINED_COLUMN, "column '%s' does not exist", 1);
     ADD_MESSAGE(UNDEFINED_FUNCTION, "function does not exist: %s", 1);
+    ADD_MESSAGE(UNDEFINED_PARTITION_METHOD, "table '%s' is not a partitioned 
table", 1);
     ADD_MESSAGE(UNDEFINED_PARTITION, "partition '%s' does not exist", 1);
-    ADD_MESSAGE(UNDEFINED_PARTITION_KEY, "'%s' column is not the partition 
key", 1);
+    ADD_MESSAGE(UNDEFINED_PARTITION_KEY, "'%s' column is not a partition key", 
1);
     ADD_MESSAGE(UNDEFINED_OPERATOR, "operator does not exist: '%s'", 1);
     ADD_MESSAGE(UNDEFINED_INDEX_FOR_TABLE, "index ''%s' does not exist", 1);
     ADD_MESSAGE(UNDEFINED_INDEX_FOR_COLUMNS, "index does not exist for '%s' 
columns of '%s' table", 2);
@@ -81,11 +84,12 @@ public class ErrorMessages {
 
     ADD_MESSAGE(AMBIGUOUS_TABLE, "table name '%s' is ambiguous", 1);
     ADD_MESSAGE(AMBIGUOUS_COLUMN, "column name '%s' is ambiguous", 1);
+    ADD_MESSAGE(AMBIGUOUS_FUNCTION, "function '%s' is ambiguous", 1);
 
     ADD_MESSAGE(DIVISION_BY_ZERO, "Division by zero: %s", 1);
 
     ADD_MESSAGE(DATATYPE_MISMATCH,
-        "column \"%s\" is of type %s but expression %s is of type %s", 4);
+        "column '%s' is of type %s but expression %s is of type %s", 4);
 
     ADD_MESSAGE(SET_OPERATION_SCHEMA_MISMATCH, "each %s query must have the 
same number of columns", 1);
     ADD_MESSAGE(SET_OPERATION_DATATYPE_MISMATCH, "%s types %s and %s cannot be 
matched");
@@ -93,9 +97,14 @@ public class ErrorMessages {
     ADD_MESSAGE(CAT_UPGRADE_REQUIRED, "catalog must be upgraded");
     ADD_MESSAGE(CAT_CANNOT_CONNECT, "cannot connect metadata store '%s': %s", 
2);
 
-    ADD_MESSAGE(MDC_NO_MATCHED_DATATYPE, "no matched type for %s", 1);
+    ADD_MESSAGE(LMD_NO_MATCHED_DATATYPE, "no matched type for %s", 1);
 
-    ADD_MESSAGE(UNKNOWN_DATAFORMAT, "Unknown data format: '%s'", 1);
+    // Storage and Data Format
+    ADD_MESSAGE(UNAVAILABLE_TABLE_LOCATION, "unavailable table location '%s': 
%s", 2);
+    ADD_MESSAGE(UNKNOWN_DATAFORMAT, "unknown data format: '%s'", 1);
+    ADD_MESSAGE(UNSUPPORTED_DATATYPE, "unsupported data type: '%s'", 1);
+    ADD_MESSAGE(INVALID_TABLE_PROPERTY, "invalid table property '%s': '%s'", 
2);
+    ADD_MESSAGE(MISSING_TABLE_PROPERTY, "table property '%s' required for 
'%s'", 2);
 
     ADD_MESSAGE(AMBIGUOUS_PARTITION_DIRECTORY, "There is a directory which is 
assumed to be a partitioned directory" +
       " : '%s'", 1);
@@ -119,7 +128,7 @@ public class ErrorMessages {
 
   public static String getInternalErrorMessage(Throwable t) {
     if (t.getMessage() != null) {
-      return MESSAGES.get(INTERNAL_ERROR).getFirst() + ": " + t.getMessage();
+      return String.format(MESSAGES.get(INTERNAL_ERROR).getFirst(), 
t.getMessage());
     } else {
       return getInternalErrorMessage();
     }

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/ExceptionUtil.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/ExceptionUtil.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/ExceptionUtil.java
index bc01cb9..71dcfc4 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/ExceptionUtil.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/ExceptionUtil.java
@@ -18,12 +18,143 @@
 
 package org.apache.tajo.exception;
 
+import com.google.common.collect.Maps;
 import org.apache.commons.logging.Log;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.tajo.common.TajoDataTypes.DataType;
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+import java.lang.reflect.Constructor;
+import java.util.Map;
+
+import static org.apache.tajo.error.Errors.ResultCode.*;
+import static org.apache.tajo.exception.ReturnStateUtil.isError;
 
 public class ExceptionUtil {
 
+  static Map<Errors.ResultCode, Class<? extends DefaultTajoException>> 
EXCEPTIONS = Maps.newHashMap();
+
+  static {
+
+    // General Errors
+    ADD_EXCEPTION(INTERNAL_ERROR, TajoInternalError.class);
+    ADD_EXCEPTION(FEATURE_NOT_SUPPORTED, UnsupportedException.class);
+    ADD_EXCEPTION(NOT_IMPLEMENTED, NotImplementedException.class);
+
+    // Query Management and Scheduler
+    ADD_EXCEPTION(QUERY_NOT_FOUND, QueryNotFoundException.class);
+
+    // Syntax Error or Access Rule Violation
+    ADD_EXCEPTION(SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION, SQLSyntaxError.class);
+    ADD_EXCEPTION(SYNTAX_ERROR, SQLSyntaxError.class);
+    ADD_EXCEPTION(INSUFFICIENT_PRIVILEGE, 
InsufficientPrivilegeException.class);
+
+    ADD_EXCEPTION(UNDEFINED_TABLESPACE, UndefinedTablespaceException.class);
+    ADD_EXCEPTION(UNDEFINED_DATABASE, UndefinedDatabaseException.class);
+    // ADD_EXCEPTION(UNDEFINED_SCHEMA, );
+    ADD_EXCEPTION(UNDEFINED_TABLE, UndefinedTableException.class);
+    ADD_EXCEPTION(UNDEFINED_COLUMN, UndefinedColumnException.class);
+    ADD_EXCEPTION(UNDEFINED_FUNCTION, UndefinedFunctionException.class);
+    ADD_EXCEPTION(UNDEFINED_PARTITION, UndefinedPartitionException.class);
+    ADD_EXCEPTION(UNDEFINED_PARTITION_KEY, 
UndefinedPartitionKeyException.class);
+    ADD_EXCEPTION(UNDEFINED_OPERATOR, UndefinedOperatorException.class);
+
+    ADD_EXCEPTION(DUPLICATE_TABLESPACE, DuplicateTableException.class);
+    ADD_EXCEPTION(DUPLICATE_DATABASE, DuplicateDatabaseException.class);
+    // ADD_EXCEPTION(DUPLICATE_SCHEMA, );
+    ADD_EXCEPTION(DUPLICATE_TABLE, DuplicateTableException.class);
+    ADD_EXCEPTION(DUPLICATE_COLUMN, DuplicateColumnException.class);
+    // ADD_EXCEPTION(DUPLICATE_ALIAS, );
+    ADD_EXCEPTION(DUPLICATE_INDEX, DuplicateIndexException.class);
+    ADD_EXCEPTION(DUPLICATE_PARTITION, DuplicatePartitionException.class);
+
+    ADD_EXCEPTION(AMBIGUOUS_TABLE, AmbiguousTableException.class);
+    ADD_EXCEPTION(AMBIGUOUS_COLUMN, AmbiguousColumnException.class);
+    ADD_EXCEPTION(AMBIGUOUS_FUNCTION, AmbiguousFunctionException.class);
+
+    ADD_EXCEPTION(DATATYPE_MISMATCH, DataTypeMismatchException.class);
+
+    ADD_EXCEPTION(UNAVAILABLE_TABLE_LOCATION, 
UnavailableTableLocationException.class);
+    ADD_EXCEPTION(UNKNOWN_DATAFORMAT, UnknownDataFormatException.class);
+    ADD_EXCEPTION(UNSUPPORTED_DATATYPE, UnsupportedDataTypeException.class);
+    ADD_EXCEPTION(INVALID_TABLE_PROPERTY, InvalidTablePropertyException.class);
+    ADD_EXCEPTION(MISSING_TABLE_PROPERTY, MissingTablePropertyException.class);
+  }
+
+  private static void ADD_EXCEPTION(Errors.ResultCode code, Class<? extends 
DefaultTajoException> cls) {
+    EXCEPTIONS.put(code, cls);
+  }
+
+  /**
+   * If the exception is equivalent to the error corresponding to the expected 
exception, throws the exception.
+   * It is used to throw an exception for a error.
+   *
+   * @param state ReturnState
+   * @param clazz Exception class corresponding to the expected
+   * @param <T> Exception class
+   * @throws T Exception
+   */
+  public static <T extends TajoException> void throwsIfThisError(ReturnState 
state, Class<T> clazz) throws T {
+    if (isError(state)) {
+      T exception = (T) toTajoException(state);
+      if (exception.getClass().equals(clazz)) {
+        throw exception;
+      }
+    }
+  }
+
+  /**
+   * It can throw any TajoException if any error occurs.
+   *
+   * @param state
+   * @throws TajoException
+   */
+  public static void throwIfError(ReturnState state) throws TajoException {
+    if (isError(state)) {
+      throw toTajoException(state);
+    }
+  }
+
+  public static DefaultTajoException toTajoExceptionCommon(ReturnState state) {
+    if (state.getReturnCode() == Errors.ResultCode.INTERNAL_ERROR) {
+      return new TajoInternalError(state);
+
+    } else if (EXCEPTIONS.containsKey(state.getReturnCode())) {
+      Object exception;
+      try {
+        Class clazz = EXCEPTIONS.get(state.getReturnCode());
+        Constructor c = clazz.getConstructor(ReturnState.class);
+        exception = c.newInstance(new Object[]{state});
+      } catch (Throwable t) {
+        throw new TajoInternalError(t);
+      }
+
+      if (exception instanceof TajoException) {
+        return (TajoException) exception;
+      } else if (exception instanceof TajoRuntimeException) {
+        return ((TajoRuntimeException) exception);
+      } else {
+        return ((TajoError) exception);
+      }
+
+    } else {
+      throw new TajoInternalError("Unknown exception: [" + 
state.getReturnCode().name() +"] " + state.getMessage());
+    }
+  }
+
+  public static TajoException toTajoException(ReturnState state) throws 
TajoRuntimeException, TajoError {
+    DefaultTajoException e = toTajoExceptionCommon(state);
+
+    if (e instanceof TajoException) {
+      return (TajoException) e;
+    } else if (e instanceof TajoRuntimeException) {
+      throw ((TajoRuntimeException) e);
+    } else {
+      throw ((TajoError) e);
+    }
+  }
+
   /**
    * Determine if a Throwable has Tajo's ReturnCode and error message.
    *
@@ -31,7 +162,7 @@ public class ExceptionUtil {
    * @return true if a Throwable has Tajo's ReturnCode and error message.
    */
   public static boolean isExceptionWithResultCode(Throwable t) {
-    return t instanceof TajoExceptionInterface;
+    return t instanceof DefaultTajoException;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/InsufficientPrivilegeException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/InsufficientPrivilegeException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/InsufficientPrivilegeException.java
new file mode 100644
index 0000000..f952848
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/InsufficientPrivilegeException.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors.ResultCode;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class InsufficientPrivilegeException extends TajoException {
+
+  public InsufficientPrivilegeException(ReturnState state) {
+    super(state);
+  }
+
+  public InsufficientPrivilegeException(String towhat) {
+    super(ResultCode.INSUFFICIENT_PRIVILEGE, towhat);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/InternalException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/InternalException.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/InternalException.java
deleted file mode 100644
index af4ee5c..0000000
--- a/tajo-common/src/main/java/org/apache/tajo/exception/InternalException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 
- */
-package org.apache.tajo.exception;
-
-import java.io.IOException;
-
-public class InternalException extends IOException {
-       private static final long serialVersionUID = -262149616685882358L;
-
-       public InternalException() {
-       }
-       
-       public InternalException(String message) {
-               super(message);
-       }
-       
-       public InternalException(String message, Exception t) {
-         super(message, t);
-       }
-       
-       public InternalException(Throwable t) {
-         super(t);
-       }
-}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/InvalidDataTypeException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/InvalidDataTypeException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/InvalidDataTypeException.java
index 9f470f2..fd2f0de 100644
--- 
a/tajo-common/src/main/java/org/apache/tajo/exception/InvalidDataTypeException.java
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/InvalidDataTypeException.java
@@ -18,12 +18,17 @@
 
 package org.apache.tajo.exception;
 
-import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
 
 public class InvalidDataTypeException extends TajoRuntimeException {
 
+  public InvalidDataTypeException(ReturnState state) {
+    super(state);
+  }
+
   public InvalidDataTypeException(DataType dataType) {
     super(Errors.ResultCode.INVALID_DATATYPE, dataType.getType().name());
   }

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/InvalidNameException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/InvalidNameException.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/InvalidNameException.java
new file mode 100644
index 0000000..e092dc0
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/InvalidNameException.java
@@ -0,0 +1,34 @@
+/*
+ * Lisensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class InvalidNameException extends TajoException {
+
+  public InvalidNameException(ReturnState state) {
+    super(state);
+  }
+
+       public InvalidNameException(String databaseName) {
+               super(Errors.ResultCode.INVALID_NAME, databaseName);
+       }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/InvalidOperationException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/InvalidOperationException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/InvalidOperationException.java
index f5de632..5e48113 100644
--- 
a/tajo-common/src/main/java/org/apache/tajo/exception/InvalidOperationException.java
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/InvalidOperationException.java
@@ -23,9 +23,6 @@ import static org.apache.tajo.common.TajoDataTypes.Type;
 public class InvalidOperationException extends RuntimeException {
        private static final long serialVersionUID = -7689027447969916148L;
 
-       /**
-        * 
-        */
        public InvalidOperationException() {
        }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/InvalidTablePropertyException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/InvalidTablePropertyException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/InvalidTablePropertyException.java
new file mode 100644
index 0000000..1d0615f
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/InvalidTablePropertyException.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors.ResultCode;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class InvalidTablePropertyException extends TajoException {
+
+  public InvalidTablePropertyException(ReturnState e) {
+    super(e);
+  }
+
+  public InvalidTablePropertyException(String propertyName, String reason) {
+    super(ResultCode.INVALID_TABLE_PROPERTY, propertyName, reason);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/LMDNoMatchedDatatypeException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/LMDNoMatchedDatatypeException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/LMDNoMatchedDatatypeException.java
new file mode 100644
index 0000000..9b18740
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/LMDNoMatchedDatatypeException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class LMDNoMatchedDatatypeException extends TajoException {
+
+  @SuppressWarnings("unused")
+  public LMDNoMatchedDatatypeException(ReturnState e) {
+    super(e);
+  }
+
+  public LMDNoMatchedDatatypeException(String dataType) {
+    super(Errors.ResultCode.LMD_NO_MATCHED_DATATYPE, dataType);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/MetadataConnectionException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/MetadataConnectionException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/MetadataConnectionException.java
new file mode 100644
index 0000000..6a1c6c8
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/MetadataConnectionException.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors.ResultCode;
+
+/**
+ * Tajo Metadata Connector's connection error
+ */
+public class MetadataConnectionException extends TajoError {
+
+  public MetadataConnectionException(String uri, Throwable t) {
+    super(ResultCode.CAT_CANNOT_CONNECT, t, uri, t.getMessage());
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/MissingTablePropertyException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/MissingTablePropertyException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/MissingTablePropertyException.java
new file mode 100644
index 0000000..9c2a868
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/MissingTablePropertyException.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors.ResultCode;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class MissingTablePropertyException extends TajoException {
+
+  public MissingTablePropertyException(ReturnState e) {
+    super(e);
+  }
+
+  public MissingTablePropertyException(String propertyName, String table) {
+    super(ResultCode.MISSING_TABLE_PROPERTY, propertyName, table);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/NotImplementedException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/NotImplementedException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/NotImplementedException.java
new file mode 100644
index 0000000..822eea1
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/NotImplementedException.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class NotImplementedException extends TajoRuntimeException {
+  private static final long serialVersionUID = -5467580471721530536L;
+
+  public NotImplementedException() {
+    super(Errors.ResultCode.NOT_IMPLEMENTED,
+        Thread.currentThread().getStackTrace()[1].getClassName());
+  }
+
+  public NotImplementedException(ReturnState state) {
+    super(state);
+  }
+
+  public NotImplementedException(String featureName) {
+    super(Errors.ResultCode.NOT_IMPLEMENTED, featureName);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/QueryFailedException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/QueryFailedException.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/QueryFailedException.java
new file mode 100644
index 0000000..97b184e
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/QueryFailedException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class QueryFailedException extends TajoException {
+
+  @SuppressWarnings("unused")
+  public QueryFailedException(ReturnState e) {
+    super(e);
+  }
+
+  public QueryFailedException(String cause) {
+    super(Errors.ResultCode.QUERY_FAILED, cause);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/QueryKilledException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/QueryKilledException.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/QueryKilledException.java
new file mode 100644
index 0000000..ef11bce
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/QueryKilledException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class QueryKilledException extends TajoException {
+
+  @SuppressWarnings("unused")
+  public QueryKilledException(ReturnState e) {
+    super(e);
+  }
+
+  public QueryKilledException() {
+    super(Errors.ResultCode.QUERY_KILLED);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/QueryNotFoundException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/QueryNotFoundException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/QueryNotFoundException.java
new file mode 100644
index 0000000..0ab9737
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/QueryNotFoundException.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class QueryNotFoundException extends TajoException {
+
+  public QueryNotFoundException(ReturnState state) {
+    super(state);
+  }
+
+  public QueryNotFoundException(String queryId) {
+    super(Errors.ResultCode.QUERY_NOT_FOUND, queryId);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/ReturnStateUtil.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/ReturnStateUtil.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/ReturnStateUtil.java
index 81554c4..169c166 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/ReturnStateUtil.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/ReturnStateUtil.java
@@ -20,14 +20,7 @@ package org.apache.tajo.exception;
 
 import com.google.common.base.Preconditions;
 import org.apache.tajo.QueryId;
-import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.error.Errors.ResultCode;
-import org.apache.tajo.exception.ErrorMessages;
-import org.apache.tajo.exception.ErrorUtil;
-import org.apache.tajo.exception.ExceptionUtil;
-import org.apache.tajo.exception.TajoExceptionInterface;
-import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos;
 import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
 import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.StringListResponse;
 import org.apache.tajo.util.StringUtils;
@@ -45,6 +38,12 @@ public class ReturnStateUtil {
     OK = builder.build();
   }
 
+  /**
+   * Throw a TajoRuntimeException. It is usually used for unexpected 
exceptions.
+   *
+   * @param state ReturnState
+   * @return True if no error.
+   */
   public static boolean ensureOk(ReturnState state) {
     if (isError(state)) {
       throw new TajoRuntimeException(state);
@@ -65,13 +64,6 @@ public class ReturnStateUtil {
         .build();
   }
 
-  public static ReturnState returnError(ResultCode code) {
-    ReturnState.Builder builder = ReturnState.newBuilder();
-    builder.setReturnCode(code);
-    builder.setMessage(ErrorMessages.getMessage(code));
-    return builder.build();
-  }
-
   public static ReturnState returnError(ResultCode code, String...args) {
     Preconditions.checkNotNull(args);
 
@@ -85,7 +77,7 @@ public class ReturnStateUtil {
     ReturnState.Builder builder = ReturnState.newBuilder();
 
     if (ExceptionUtil.isExceptionWithResultCode(t)) {
-      TajoExceptionInterface tajoException = (TajoExceptionInterface) t;
+      DefaultTajoException tajoException = (DefaultTajoException) t;
       builder.setReturnCode(tajoException.getErrorCode());
       builder.setMessage(tajoException.getMessage());
     } else {
@@ -130,7 +122,7 @@ public class ReturnStateUtil {
   }
 
   public static ReturnState errNoSuchQueryId(QueryId queryId) {
-    return returnError(ResultCode.NO_SUCH_QUERYID, queryId.toString());
+    return returnError(ResultCode.QUERY_NOT_FOUND, queryId.toString());
   }
 
   public static ReturnState errNoData(QueryId queryId) {
@@ -146,7 +138,7 @@ public class ReturnStateUtil {
   }
 
   public static ReturnState errNoSessionVar(String varName) {
-    return returnError(ResultCode.NO_SUCH_QUERYID, varName);
+    return returnError(ResultCode.QUERY_NOT_FOUND, varName);
   }
 
   public static ReturnState errInsufficientPrivilege(String message) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/SQLExceptionUtil.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/SQLExceptionUtil.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/SQLExceptionUtil.java
index deeb7f9..e326ae2 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/SQLExceptionUtil.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/SQLExceptionUtil.java
@@ -19,9 +19,7 @@
 package org.apache.tajo.exception;
 
 import com.google.common.collect.Maps;
-import org.apache.log4j.spi.ErrorCode;
 import org.apache.tajo.error.Errors.ResultCode;
-import org.apache.tajo.exception.ErrorMessages;
 import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
 
 import java.sql.SQLException;

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/SQLSyntaxError.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/SQLSyntaxError.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/SQLSyntaxError.java
new file mode 100644
index 0000000..512ba36
--- /dev/null
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/SQLSyntaxError.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class SQLSyntaxError extends TajoRuntimeException {
+  private static final long serialVersionUID = 5388279335175632067L;
+
+  public SQLSyntaxError(ReturnState state) {
+    super(state);
+  }
+
+  public SQLSyntaxError(String errorMessage) {
+    super(Errors.ResultCode.SYNTAX_ERROR, errorMessage);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/TajoError.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/exception/TajoError.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/TajoError.java
index 765ead3..8618633 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/TajoError.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/TajoError.java
@@ -19,13 +19,12 @@
 package org.apache.tajo.exception;
 
 import org.apache.tajo.error.Errors.ResultCode;
-import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos;
 import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
 
 /**
  * Unrecoverable errors
  */
-public class TajoError extends Error implements TajoExceptionInterface {
+public class TajoError extends Error implements DefaultTajoException {
   private ResultCode code;
 
   public TajoError(ReturnState state) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/TajoException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/TajoException.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/TajoException.java
index e0e2ccb..b5d236e 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/TajoException.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/TajoException.java
@@ -25,7 +25,7 @@ import 
org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
  * TajoException contains all exceptions with any exact reason.
  * It always have an exact error code and an error message.
  */
-public class TajoException extends Exception implements TajoExceptionInterface 
{
+public class TajoException extends Exception implements DefaultTajoException {
   private ResultCode code;
 
   public TajoException(ReturnState e) {
@@ -33,7 +33,7 @@ public class TajoException extends Exception implements 
TajoExceptionInterface {
     this.code = e.getReturnCode();
   }
 
-  public TajoException(TajoRuntimeException e) {
+  public TajoException(DefaultTajoException e) {
     super(e.getMessage());
     this.code = e.getErrorCode();
   }

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/TajoExceptionInterface.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/TajoExceptionInterface.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/TajoExceptionInterface.java
deleted file mode 100644
index e0444a0..0000000
--- 
a/tajo-common/src/main/java/org/apache/tajo/exception/TajoExceptionInterface.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tajo.exception;
-
-import org.apache.tajo.error.Errors.ResultCode;
-
-/**
- * Abstracted exception or error interface. TajoException and
- * TajoRuntimeException always have a ResultCode and a message.
- * This interface helps routines access both TajoException and
- * TajoRuntimeException in a common way.
- */
-public interface TajoExceptionInterface {
-  ResultCode getErrorCode();
-
-  String getMessage();
-}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/TajoInternalError.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/TajoInternalError.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/TajoInternalError.java
index 072636b..4decd21 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/TajoInternalError.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/TajoInternalError.java
@@ -19,7 +19,6 @@
 package org.apache.tajo.exception;
 
 import org.apache.tajo.error.Errors.ResultCode;
-import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos;
 import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
 
 /**

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/TajoRuntimeException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/TajoRuntimeException.java 
b/tajo-common/src/main/java/org/apache/tajo/exception/TajoRuntimeException.java
index 69da2a8..071efa0 100644
--- 
a/tajo-common/src/main/java/org/apache/tajo/exception/TajoRuntimeException.java
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/TajoRuntimeException.java
@@ -26,7 +26,7 @@ import 
org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
  *
  * @see @{link TajoException}
  */
-public class TajoRuntimeException extends RuntimeException implements 
TajoExceptionInterface {
+public class TajoRuntimeException extends RuntimeException implements 
DefaultTajoException {
   private ResultCode code;
 
   public TajoRuntimeException(ReturnState state) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/UnavailableTableLocationException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/UnavailableTableLocationException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/UnavailableTableLocationException.java
new file mode 100644
index 0000000..b0d19e6
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/UnavailableTableLocationException.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class UnavailableTableLocationException extends TajoException {
+
+  public UnavailableTableLocationException(ReturnState e) {
+    super(e);
+  }
+
+  public UnavailableTableLocationException(String uri, String reason) {
+    super(Errors.ResultCode.UNAVAILABLE_TABLE_LOCATION, uri, reason);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/UndefinedColumnException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/UndefinedColumnException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/UndefinedColumnException.java
new file mode 100644
index 0000000..954107b
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/UndefinedColumnException.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+
+import org.apache.tajo.error.Errors.ResultCode;
+import org.apache.tajo.exception.TajoException;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class UndefinedColumnException extends TajoException {
+       private static final long serialVersionUID = 277182608283894937L;
+
+  public UndefinedColumnException(ReturnState state) {
+    super(state);
+  }
+
+       public UndefinedColumnException(String columnName) {
+               super(ResultCode.UNDEFINED_COLUMN, columnName);
+       }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-common/src/main/java/org/apache/tajo/exception/UndefinedDatabaseException.java
----------------------------------------------------------------------
diff --git 
a/tajo-common/src/main/java/org/apache/tajo/exception/UndefinedDatabaseException.java
 
b/tajo-common/src/main/java/org/apache/tajo/exception/UndefinedDatabaseException.java
new file mode 100644
index 0000000..bf04df8
--- /dev/null
+++ 
b/tajo-common/src/main/java/org/apache/tajo/exception/UndefinedDatabaseException.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.exception;
+
+
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.exception.TajoException;
+import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+
+public class UndefinedDatabaseException extends TajoException {
+       private static final long serialVersionUID = 277182608283894937L;
+
+  public UndefinedDatabaseException(ReturnState state) {
+    super(state);
+  }
+
+       public UndefinedDatabaseException(String dbName) {
+               super(Errors.ResultCode.UNDEFINED_DATABASE, dbName);
+       }
+}

Reply via email to