Forum Discussion

AngelaIp's avatar
AngelaIp
Ideator I
2 years ago
Solved

How to get more specific error details from getErrorDetail() ?

Hi community,

we can use getErrorString() and getErrorDetail() to catch error information from failed queries.

getErrorString() only contains a short description, while getErrorDetail returns the short-description + some long text + some XML content.

Does anyone know a way to only get the xml part of getErrorDetails() that contain the item information? 

I most of the time use getErrorString, but I have a use case for mass operations, where the xml part contains the relevant information if something went wrong. 

I want to provide more precise feedback to the end users (what has failed exactly), but also use the xml information to call some "automatically repair if this error happens" function. But for this function I would need the item information in the xml part.

Does anyone has and idea to get more specific error details?

Thanks and best regards!

Angela

  • AngelaIp's avatar
    AngelaIp
    8 months ago

    Use case is the following. I have an import feature for our custom Conflict Mineral Solution. Basically I read the data from the source document and add new items.

    I use the proven concept from the end of this blog: https://aras.com/en/blog/aras-best-practices-server-side-code. Instead of doing multiple applies I execute one large AML query to add all the data.

    Technically the use case is comparable to the mass import of Manufacturer Parts. Import only works if the "Manufacturer" exists in the database. If one Manufacturer is missing, the whole query will fail. But we cannot easy tell, which Manufacturer was missing. But I discovered that in my use case the missing Manufacturer/Smelter is Part of getErrorDetail().

    The idea was to catch the Smelter number from getErrorDetail and open up a new Form so can add the missing smelter. That was the reason for the title of this post.

    I want to avoid to use add/merge to add the missing data automatically. Conflict Mineral data is standardized, but companies show great creativity in not following the standard AT ALL. There is certain data that you just don´t want to automatically add to your db.

    But I think I found a solution while writing this answer. 

    I was probably too focused on the "do something AFTER the error occured" concept. Maybe I should prevent the error from the start. 

    I could do one "get" query first with many logic or´s to check if we already know all the listed Manufacturers. Than match the result with the data we want to import. If data is missing, offer the user the option to add the missing elements before trying the actual import.

    This should do the job. But I am open to even better ideas :). 

6 Replies

  • Former Member's avatar
    Former Member

    Certainly! To extract specific information from the XML part of getErrorDetails(), you can use XML parsing techniques. Utilize an XML parser to extract the relevant item information from the detailed error response. Once you have parsed the XML, you can access the specific elements or attributes containing the item details.

    For instance, in many programming languages, you can use libraries like DOMParser or XMLPullParser to parse XML. Extract the necessary information, such as item details, from the parsed XML structure. This way, you can provide more precise feedback to end-users and implement automatic error resolution based on the extracted item information from the XML part of getErrorDetails().

  • I'm happy to help! Get specified information from getErrorDetails()'s XML component using XML parsing. Use an XML parser to get item data from the lengthy error response. Parsing the XML allows access to item details components or attributes. 

    run 3

    • AngelaIp's avatar
      AngelaIp
      Ideator I

      None of the two AI spam bot answers is useful.

      I am happy that spammers at least try to cover their spam with "something useful", but please try to optimize your spam that it works better in the context of Innovator.

  • Hi community,

    this post is pretty old but the use case is still up-to-date.

    Does anyone have an overview of error codes that are returned with getErrorCode()? Code"0" is helpful for queries were no items were found, while the query itself still worked. 

    I wonder if this function contains some else that is useful?

    • christopher_gillis's avatar
      christopher_gillis
      New Member

      Hi Angela,

      The getErrorCode function returns the information found in the faultcode portion of the Soap response you get back from a query. While there do appear to be some pre-defined faultcodes as part of the Soap standard, custom faultcodes are also allowed. Because of this, there isn't a flat list of faultcodes that you can check against. I believe this also means that the usefulness of the faultcode you get back from calling getErrorCode will be dependent on the exact query you're making. 

      • AngelaIp's avatar
        AngelaIp
        Ideator I

        Use case is the following. I have an import feature for our custom Conflict Mineral Solution. Basically I read the data from the source document and add new items.

        I use the proven concept from the end of this blog: https://aras.com/en/blog/aras-best-practices-server-side-code. Instead of doing multiple applies I execute one large AML query to add all the data.

        Technically the use case is comparable to the mass import of Manufacturer Parts. Import only works if the "Manufacturer" exists in the database. If one Manufacturer is missing, the whole query will fail. But we cannot easy tell, which Manufacturer was missing. But I discovered that in my use case the missing Manufacturer/Smelter is Part of getErrorDetail().

        The idea was to catch the Smelter number from getErrorDetail and open up a new Form so can add the missing smelter. That was the reason for the title of this post.

        I want to avoid to use add/merge to add the missing data automatically. Conflict Mineral data is standardized, but companies show great creativity in not following the standard AT ALL. There is certain data that you just don´t want to automatically add to your db.

        But I think I found a solution while writing this answer. 

        I was probably too focused on the "do something AFTER the error occured" concept. Maybe I should prevent the error from the start. 

        I could do one "get" query first with many logic or´s to check if we already know all the listed Manufacturers. Than match the result with the data we want to import. If data is missing, offer the user the option to add the missing elements before trying the actual import.

        This should do the job. But I am open to even better ideas :).