I am playing with adding operations to an existing data model. I need to create some custom exception types that can be thrown by the operations when the data is in specific states.
It seems intuitive that the EExceptions property of the operation should be used. This forces me to create the exception classes within the data model. This would be fine, but I cannot find any way of creating a Throwable class and so create an error in the generated code.
What is the recommended way of achieving this or am I approaching the problem from the wrong angle?
On 18/01/2013 12:43 PM, Jack Mising name wrote:
> I am playing with adding operations to an existing data model. I need
> to create some custom exception types that can be thrown by the
> operations when the data is in specific states.
>
> It seems intuitive that the EExceptions property of the operation
> should be used.
Yes, that's the intent.
> This forces me to create the exception classes within the data model.
I'd expect you to use EDataTypes to wrap your exception classes and then
use those in the operation's exceptions list.
> This would be fine, but I cannot find any way of creating a Throwable
> class and so create an error in the generated code.
Create an EDataType that wraps java.lang.Throwable.
>
> What is the recommended way of achieving this or am I approaching the
> problem from the wrong angle?
You can look at how Ecore.ecore has EInvocationTargetException that
wraps java.lang.reflect.InvocationTargetException. Note that the type
is marked as Serializeable false; you won't need your exception data
types to support string conversion in the factory, so best to mark them
as not serializeable (in the EMF data type sense).
>
> BTW :
> Eclipse : 4.2.1
> Ecore : 2.8.1
> Ecore Edit : 2.8.0
>
> TIA,
>
> Jack
> This forces me to create the exception classes within the data model.
I'd expect you to use EDataTypes to wrap your exception classes and then
use those in the operation's exceptions list.
Aha! I had assumed that with the name 'EException' there would be a defined way of expressing exception objects within the model.
Creating them outside of the model and wrapping them in seems to work. Thanks!