Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: MattAdamson on October 05, 2006, 03:00:22 am

Title: Issue with GetLastError not returning description
Post by: MattAdamson on October 05, 2006, 03:00:22 am
Guys,

I'm not overly happy with the inconsistent in the object model between methods throwing exceptions or using return values e.g. many Update methods contain a boolean flag. If this fails the documentation indicates GetLastError should be called to extract the error.

I've never had an issue with Update methods failed, only exceptions raised until now. I have the following code

EA.Connector sourceElementConnector = (EA.Connector)sourceElement.Connectors.AddNew("",
                                                              "Association");
sourceElementConnector.SupplierID = ((EA.Element)targetElement).ElementID;
sourceElementConnector.Stereotype = stereotype;

if(sourceElementConnector.Update())
{
       throw new ApplicationException(String.Format("Failed to associate elements and update source connector for source element name='{0}' Err='{1}'",
sourceElement.Name,
sourceElementConnector.GetLastError()));

Has anyone else had this issue, is there any other way to extract error information here. Should I be accessing the GetLastError method on another object other than the one for which the Update method failed.

Title: Re: Issue with GetLastError not returning descript
Post by: MattAdamson on October 10, 2006, 08:43:06 am

:-[, if checking Update should be ! Update
Title: Re: Issue with GetLastError not returning descript
Post by: bittercoder on December 12, 2006, 02:32:42 pm
Is the issue that GetLastError() on the element is returning an empty string... or are just generally annoyed with the inconsistency of the model ;)
Title: Re: Issue with GetLastError not returning descript
Post by: MattAdamson on December 12, 2006, 10:11:24 pm
Inconsistency, i.e. having to check the return value and whether an exception is thrown.
Title: Re: Issue with GetLastError not returning descript
Post by: bittercoder on December 12, 2006, 10:28:45 pm
Yeah, the inconsitences are anoying - I've written a managed wrapper over the top of the EA COM components I work with to shield me from some of this stuff..

In some rate situations it may be more efficient to have boolean flags returned though (ie. if your looping through a number of tasks in an add-in and want to accumulate failure information, as opposed to imediately bailing out - the cost of raising exceptions, especially across the managed/unmanaged boundry can be time consuming).