Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Modeling Custom Exceptions?
Modeling Custom Exceptions? [message #1002315] Fri, 18 January 2013 11:43 Go to next message
Jack Mising name is currently offline Jack Mising nameFriend
Messages: 18
Registered: August 2010
Junior Member
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?

BTW :
Eclipse : 4.2.1
Ecore : 2.8.1
Ecore Edit : 2.8.0

TIA,

Jack
Re: Modeling Custom Exceptions? [message #1002322 is a reply to message #1002315] Fri, 18 January 2013 11:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Jack,

Comments below.

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


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Modeling Custom Exceptions? [message #1002345 is a reply to message #1002322] Fri, 18 January 2013 12:35 Go to previous message
Jack Mising name is currently offline Jack Mising nameFriend
Messages: 18
Registered: August 2010
Junior Member
Ed Merks wrote on Fri, 18 January 2013 11:55

> 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!
Previous Topic:Enumerator to EEnum navigation
Next Topic:[CDO] [DAWN] State of the project?
Goto Forum:
  


Current Time: Wed Apr 24 21:21:27 GMT 2024

Powered by FUDForum. Page generated in 0.04075 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top