*---------------------- Location Section ------------------------ * Library: Aqueueprocess.vcx * Class: Assignqueues * Method: Customerror() *----------------------- Usage Section -------------------------- *) Description: *) * Scope: Public * Parameters: *$ Usage: *$ * Returns: *--------------------- Maintenance Section ---------------------- * Change Log: * CREATED 06/01/2005 - NN * MODIFIED *---------------------------------------------------------------- lparameters toErr if vartype(m.toErr) = "O" && real exception occurred if m.toErr.ErrorNo <> 1098 && Custom error local lcError, lnI, laErrors[1] lcError = "Encountered an error #" + transform(m.toErr.ErrorNo) + " " + ; m.toErr.message + " in method " + m.toErr.LineContents + ; " on line # " + transform(m.toErr.lineno) + chr(13) if not inlist(type('gaErrors[1]'),"U", "L") for lnI = 1 to alen(gaErrors) lcError = m.lcError + transform(gaErrors [m.lnI]) + chr(13) next endif this.lRealError = .t. this.cError = m.lcError endif endif local lnTrxnLevel lnTrxnLevel = txnlevel( ) do while m.lnTrxnLevel > 0 rollback lnTrxnLevel = txnlevel( ) enddoMy top level method has:
local loErr set talk off set deleted on && Very important, otherwise we can pick up deleted records by mistake =aused(this.arrOriginallyUsed) with this try .CreateLogfile() ** We want to have a clear log of everything .WriteToLogFile("Started to run assigning queues process") .lRunUpdates = m.tlUpdateForms if .lRunUpdates local lcSubject lcSubject = 'TransEmployeesQueueSubject' this.oSubject = createobject(m.lcSubject) && Create "INVESTIGATOR" subject object ENDIF .OpenQueueTables() && Opens queue related tables with buffering .SetDepartment(m.tcDepartment_Code) .SetNumberOfDays(m.tnNumberOfDays) .SetQueueNameFrom(m.tcQueue_Name_From) .SetQueueNameTo(m.tcQueue_Name_To) .GetUsers(m.tcUser) .GetProfiles() .GetAlreadyScheduled() for lnI = 1 to .nNumberOfDays ldScheduled_Date = ttod(.arrQDates[m.lnI]) select c_Users go top && Very important ! scan .Assign_Accounts_To_User( ; .cQueue_Name_To, c_Users.cDepartment_Code, ; c_Users.cUserID, c_Users.iUserID, ; m.ldScheduled_Date) if .lRunUpdates .OnStateChange("SAVE") endif endscan next .WriteToLogFile("Finished to run assigning queues process") catch to loErr .CustomError(m.loErr) finally release loErr .CleanUp() endtry endwith returnAnd if I want to raise custom error I do:
* This account is already scheduled - should not happen this.cError = "The account " + ; m.lcTrans_Employees_Queues_pk + " is already scheduled!"
*---------------------- Location Section ------------------------ * Library: Aqueueprocess.vcx * Class: Assignqueues * Method: Cerror_assign() *----------------------- Usage Section -------------------------- *) Description: *) * Scope: Public * Parameters: *$ Usage: *$ * Returns: *--------------------- Maintenance Section ---------------------- * Change Log: * CREATED 06/01/2005 - NN * MODIFIED *---------------------------------------------------------------- LPARAMETERS vNewVal *To do: Modify this routine for the Assign method THIS.cError = m.vNewVal this.WriteToLogfile(this.cError) IF NOT this.lRealError ERROR this.cError && Trigger an error endif this.lRealError = .f.