Exceptional Handling: error or warning not able to catch in try catch statement

Hi All,

I created a runbase class in order to post the Free Text invoice. for tacking log I used try catch statement as below. i am getting the warning and error in infolog. but not able to catch in try catch statement. please check. any help would be appreciated.

Note: I am getting Error in CustPostInvoice.run() that i want to be capture in catch.

while(qr.next())
            {

                custInvoiceTable       = qr.get(tableNum(CustInvoiceTable));
                //while select custInvoiceTable where custInvoiceTable.RecID == "SOL_Mar_18_96"

                infolog.clear();
                checkFail = true;

                TotalRecord++;

                select RecId from custInvoiceLine where custInvoiceLine.ParentRecId == custInvoiceTable.RecId;

                    if(custInvoiceLine.RecId)
                    {
                        try
                        {       PostedFTInvoice++;
                                custPostInvoice = new CustPostInvoice(custInvoiceTable);
                                custPostInvoice.run();
                                checkFail = false;
                        }
                        catch(Exception::Error)
                        {

                            errorLine++;
                            
                             if(checkFail == true)
                            {
                                PostedFTInvoice = PostedFTInvoice - 1;
                            }

                            this.getBatchError(custInvoiceTable);//infolog.text(infologLine());

                            continue;
                        }

                }
                    else
                    {
                        NoLine++;
                        warning("Free Text Invoice: %1 do not have lines",custInvoiceTable.Bsil_ReferenceFreeInvoiceNumber);
                    }


            }
        }

        info(strFmt("Total %1 Records processed",TotalRecord));
        info(strFmt("Total %1 Free Text Invoice failed",errorLine));
        info(strFmt("Total %1 Free Text Invoice Does not Contains lines",NoLine));
        info(strFmt("Total %1 Free Text Invoice Posted",PostedFTInvoice));

Isn’t it inside a database transaction? You can’t catch error exceptions there.

Hi Martin,

Yes, Code written inside the ttsbegin and ttscommit in custpostinvoice.run(). is there any other way to track error of custpostinvoice.run() as per above code.

It doesn’t matter whether the code inside try uses transactions, the question is whether your try/catch is inside a transaction.