
/**
 * err_throw -
 *
 * (c) Copyright ABC Alon Blich Consulting Tech, Ltd.
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 *  Contact information
 *  Email: alonblich@gmail.com
 *  Phone: +972-54-218-8086
 */



&if     "{&err_xBlock7}" <> "" &then &scoped err_xLevel 7
&elseif "{&err_xBlock6}" <> "" &then &scoped err_xLevel 6
&elseif "{&err_xBlock5}" <> "" &then &scoped err_xLevel 5
&elseif "{&err_xBlock4}" <> "" &then &scoped err_xLevel 4
&elseif "{&err_xBlock3}" <> "" &then &scoped err_xLevel 3
&elseif "{&err_xBlock2}" <> "" &then &scoped err_xLevel 2
&elseif "{&err_xBlock1}" <> "" &then &scoped err_xLevel 1
&endif



&if     "{1}" = "last" &then

    err_throwExact( {&err_xError}, {&err_xErrorMsg}, {&err_xStackTrace} )

&elseif "{1}" = "last-top-level" &then

    if not err_isProcUsesSlibErr( source-procedure ) then

         err_returnError( replace( {&err_xErrorMsg}, chr(1), "~n" ) + "~n~nTrace:~n" + {&err_xStackTrace} ).
    else err_throwExact ( {&err_xError}, {&err_xErrorMsg}, {&err_xStackTrace} )

&else

    err_throw( 

        input {1}, 

        input &if  "{2}" <> "" &then            string(  {2} ) &else ? &endif 
              &if  "{3}" <> "" &then + chr(1) + string(  {3} ) &endif
              &if  "{4}" <> "" &then + chr(1) + string(  {4} ) &endif
              &if  "{5}" <> "" &then + chr(1) + string(  {5} ) &endif
              &if  "{6}" <> "" &then + chr(1) + string(  {6} ) &endif
              &if  "{7}" <> "" &then + chr(1) + string(  {7} ) &endif
              &if  "{8}" <> "" &then + chr(1) + string(  {8} ) &endif
              &if  "{9}" <> "" &then + chr(1) + string(  {9} ) &endif
              &if "{10}" <> "" &then + chr(1) + string( {10} ) &endif,

        input &if "{&err_xErrorMsgFile}" <> "" &then {&err_xErrorMsgFile} &else ? &endif )

&endif /* else */
