Book a Demo

Author Topic: Issue with GetLastError not returning description  (Read 3543 times)

MattAdamson

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Issue with GetLastError not returning description
« 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.


MattAdamson

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Issue with GetLastError not returning descript
« Reply #1 on: October 10, 2006, 08:43:06 am »

:-[, if checking Update should be ! Update

bittercoder

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
  • .Net developer
    • View Profile
Re: Issue with GetLastError not returning descript
« Reply #2 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 ;)

MattAdamson

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Issue with GetLastError not returning descript
« Reply #3 on: December 12, 2006, 10:11:24 pm »
Inconsistency, i.e. having to check the return value and whether an exception is thrown.

bittercoder

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
  • .Net developer
    • View Profile
Re: Issue with GetLastError not returning descript
« Reply #4 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).