Hi all, help me (ax2012)
I post product receipt by code but not catch when error
try
{
purchFormLetter.run();
//error not catch ?
}
}
catch(exception::Error)
{
ttsabort;
result = false;
error("Catch an error exception.");
}
Hi all, help me (ax2012)
I post product receipt by code but not catch when error
try
{
purchFormLetter.run();
//error not catch ?
}
}
catch(exception::Error)
{
ttsabort;
result = false;
error("Catch an error exception.");
}
thank you, good iead, I try
Unfortunately your screenshot doesn't show the critical piece of information - whether your catch statement is inside a database transaction or not. There may be a transaction somewhere in the code calling generateProductReceipt().
One way how to find it out is putting a breakpoint at the beginning of generateProductReceipt(), running the code with debugging and observing TtsLevel in the Autos window (Debug > Windows > Autos). If it's higher than zero, you're inside a transaction and you can't catch errors.
Hi Martin Dráb
Please use Insert > Insert Code (in the rich-formatting view) to paste source code. It preserves indentation, making code easier to read. Like this:
try { purchFormLetter.run(); //error not catch ? } } catch(Exception::Error) { ttsabort; result = false; error("Catch an error exception."); }
Then please explain your problem.
I see you have an extra } there (at line 5 or 6). Don't use ttsabort - throwing an exception aborts transactions, therefore this isn't needed.
Note that if you catch statement is inside a transaction, it'll be never called. The system aborts transactions and continues execution after the top-level transaction, therefore you must place your try/catch there.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156