Re: OCL: dealing with exceptions



Date view Thread view Subject view Author view Attachment view

From: Brian Smith (brian-l-smith@uiowa.edu)
Date: Mon 27 May 2002 - 19:33:20 BST


First, I appreciate the very detailed and informative response from both 
  you and Andreas.

I am trying to use OCL 1.4 with MOF 1.4 from OMG. MOF 1.4 has a special 
"Exception" meta-class that has no subtyping relationship to its "Class" 
or "Operation" meta-classes. In particular, Exceptions are definitely 
_not_ Classifiers in MOF. Instead, there is an association between an 
Operation and Exception to denote which Exceptions an Operation may 
raise. Furthermore, in MOF 1.4, "allInstances" has obvious semantics for 
only for Classes, not Exceptions.

I am expecting, in OCL 2.0, there would be explicit support for 
exceptions. Is that not the case?

- Brian


Anneke Kleppe wrote:
> Hi Brian,
> 
> There are two ways in which to specify exceptions in OCL, depending on 
> how your exceptions are modelled.
> When an exception is considered to be a specific operation that is 
> called when the condition occurs, you can use the following:
> 
> context yourClass:operationThatThrowsException() : SomeResultType
> pre: -- none
> post: someCondition implies exceptionHandler^handlingOperation().isSent()
> 
> someCondition can be written in exactly the same manner as in every 
> other OCL expression. This type of expression, indicating a message 
> being sent, is new to the OCL 2.0.
> 
> When an exception is specified as a class, of which a new instance has 
> to be created when the condition occurs, you can use something like the 
> following:
> 
> context yourClass:operationThatThrowsException() : SomeResultType
> pre: -- none
> post: Let e: Exception
>       in someCondition implies ( self.thrownExceptions->includes( e ) and
>                                  e.isNew() )
> 
> But as you can see, it all depends on how you have modelled your 
> exceptions in the UML part of your specification. Here I assume that 
> 'yourClass' has an association with the class 'Exception', called 
> 'thrownExceptions'. But many different approaches can be used.
> 
> Hope this helps,
> Anneke Kleppe
> 
> At 12:13 PM 22-05-2002 -0500, you wrote:
> 
>> How can I use OCL to specify the conditions under which a particilar 
>> exception is thrown by an operation? I have looked at the OCL 
>> specification and there seems to be no way to do it.
>>
>> I am looking for a way to specify exceptions that will type-check.
>>
>> Any references to information about this topic are greatly appreciated.
>>
>> Thanks,
>> Brian
>>
>>
>>
>>
>> To remove yourself from this list please mail 
>> puml-list-request@cs.york.ac.uk
>> with a message containing the word "unsubscribe".
>>
> Klasse Objecten
> Chalonhof 153
> NL - 3762 CT Soest
> The Netherlands
> voice: +31(0)35-6037646
> fax: +31(0)35-6037647
> http://www.klasse.nl <http://www.klasse.nl/>
> 

Date view Thread view Subject view Author view Attachment view