--- /dev/null
+package org.simantics.databoard.channel;\r
+\r
+import org.simantics.databoard.adapter.AdaptException;\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.binding.error.BindingException;\r
+import org.simantics.databoard.binding.mutable.Variant;\r
+\r
+/**\r
+ * Service exception is a problem in processing the service request.\r
+ * It is produces by Service Handler. Service Exception is not a communication \r
+ * error. \r
+ *\r
+ * @author Toni Kalajainen <toni.kalajainen@iki.fi>\r
+ */\r
+public abstract class ServiceException extends Exception {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ Variant error;\r
+ \r
+ public ServiceException(Variant error) {\r
+ this.error = error;\r
+ }\r
+ \r
+ public ServiceException(Binding binding, Object value) {\r
+ error = new Variant(binding, value);\r
+ }\r
+ \r
+ public Variant getError() {\r
+ return error;\r
+ }\r
+ \r
+ public Object getErrorType() {\r
+ return error.type();\r
+ }\r
+ \r
+ public Object getError(Binding binding) throws BindingException {\r
+ try {\r
+ return error.getValue(binding);\r
+ } catch (AdaptException e) {\r
+ if (e.getCause()!=null && e.getCause() instanceof BindingException) throw (BindingException) e.getCause();\r
+ throw new BindingException(e);\r
+ }\r
+ }\r
+ \r
+}\r