Better version of 'Not a single Item' Error?

Hello,

Does anyone know if it is possible to edit a piece of code to produce a more descriptive error rather than just 'Not a single Item'. I understand the logic behind why this issue occurs and I have my own ways of finding where this error occurs but it would be a lot easier if the error tells you which method it originates from. 

Thanks,

Joshua

Parents
  • Hi Joshua,

    I completely agree! This one is one of the most stupid and misleading error messages in innovator.

    Do you want to change the error message text in general? If yes, I assume it´s contained in one of the ui_resource.xml files in the codetree or a "User Message" item in the db. But maybe it´s also hardcoded in the core.

    For your own features, you can improve this one pretty easily. Normally the error occur when you want to use a property from an item that haven´t been found. So you have to catch the error event before using anything from your item.

    This variant gives a more helpful and friendly feedback to users, so you can avoid the "not a single item" error:

    Innovator inn = this.getInnovator();
    Item test = inn.newItem("Part","get");
    test.setID("132"); // this id is definitely wrong and will lead to an error later in code
    test = test.apply();
    if (test.isError())
    {
      return inn.newError("Computer says no. I cannot find anything that fits your search conditions. Some more hints: " + test.getErrorString());
    }

    string x = test.getProperty("id"); // this line would create "Not a single item" error if catch block missing
    return test;

  • Hey Angelalp,

    Thanks for your suggestion, I'll have to dive into the codetree a little more to get a better understanding. In the mean time I have been doing something similar to what you suggested but instead of the 'if (test.isError())' I use a try catch. All of the code inside the catch statement will display a more informative error message. Thanks for the help.

    Example (CSharp):

    try {

    /* All of my method code */

    } catch (Exception e) {
         Innovator inn = this.getInnovator();
         string except = e.ToString();
         int pFrom = except.IndexOf("<faultstring>") + "<faultstring>".Length;
         int pTo = except.LastIndexOf("</faultstring>");

         string finalExcept = except.Substring(pFrom, pTo - pFrom);
         Item err = inn.newError(finalExcept);
         err.setErrorSource("*Insert name of method here*");
         err.setErrorDetail(e.ToString());
         return err;
    }

    - Joshua

Reply
  • Hey Angelalp,

    Thanks for your suggestion, I'll have to dive into the codetree a little more to get a better understanding. In the mean time I have been doing something similar to what you suggested but instead of the 'if (test.isError())' I use a try catch. All of the code inside the catch statement will display a more informative error message. Thanks for the help.

    Example (CSharp):

    try {

    /* All of my method code */

    } catch (Exception e) {
         Innovator inn = this.getInnovator();
         string except = e.ToString();
         int pFrom = except.IndexOf("<faultstring>") + "<faultstring>".Length;
         int pTo = except.LastIndexOf("</faultstring>");

         string finalExcept = except.Substring(pFrom, pTo - pFrom);
         Item err = inn.newError(finalExcept);
         err.setErrorSource("*Insert name of method here*");
         err.setErrorDetail(e.ToString());
         return err;
    }

    - Joshua

Children
No Data