Forum Discussion
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