Re: Raising an exception in a callback

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Feb 26 2008 - 04:56:27 EST

  • Next message: Ilya Lazarev: "Re: Determining changes in a dataobject / modification diff"

    On Feb 26, 2008, at 11:45 AM, Alexander Lamb (dev) wrote:

    > Hello List,
    >
    > I want to prevent a delete of an object if certain attributes have
    > certain values (e.g. do not delete an invoice which has already been
    > sent).
    >
    > I registered the callback in the Modeler. Works fine.
    >
    > I do my test in the callback function I defined, it works fine.
    >
    > Except that to "stop" the delete, I raise a RuntimeException (I
    > don't see any other way). It works and is catched by the delete.
    > However I do not get my exception, but an exception Cayenne has
    > generated.
    >
    > What is the correct way to raise an exception and transfer up the
    > correct error message?
    >
    > Thanks,
    >
    > Alex

    Without looking at the code, IIRC CayenneRuntimeException.getCause()
    should store your exception.

    Andrus



    This archive was generated by hypermail 2.0.0 : Tue Feb 26 2008 - 04:57:04 EST