/*
    ####             #    #     # #
    #   #            #    #       #          The FreeWare C library for 
    #   #  ##   ###  #  # #     # ###             RISC OS machines
    #   # #  # #     # #  #     # #  #   ___________________________________
    #   # ####  ###  ##   #     # #  #                                      
    #   # #        # # #  #     # #  #    Please refer to the accompanying
    ####   ### ####  #  # ##### # ###    documentation for conditions of use
    ________________________________________________________________________

    Author:  Copyright  1995 Julian Smith
    Version: 1.00 (07 Sep 1995)
    Purpose: Making set/longjmp easier to use.
    History: 1.00 (07 Sep 1995) JS
             1.01 (10 Nov 1995) JS Calls Desk_Error2_Exit rather than 
                                   Desk_Error2_VerboseExit, to avoid pulling in
                                   the rather large Desk_Error2_VerboseExit
                                   function.
             1.02 (29 Nov 1995) JS Now passes Desk_error2_block* in call to 
                                   longjmp()
             1.03 (13 Dec 1995) JS Added Desk_jumpauto_lasterror.
*/



#include "Desk.Error2.h"
#include "Desk.Jump.h"
#include "Desk.BackTrace.h"
#include "Desk.Debug.h"


Desk_error2_block*	Desk_jumpauto_lasterror = NULL;


Desk_error2_block	*Desk_JumpAuto_Error2Handler( Desk_error2_block *error)
{
Desk_jumpauto_lasterror = error;

Desk_Debug_Printf( Desk_error_PLACE "Desk_JumpAuto_Error2Handler called. Desk_jumpauto_newestbuf = 0x%p\n", Desk_jumpauto_newestbuf);
if ( Desk_jumpauto_newestbuf)	{
	#ifdef Desk_DEBUG
		if ( Desk_debug_level>=3)	{
			Desk_Debug_Printf( Desk_error_PLACE "Just about to longjmp to Desk_jump_bug:\n");
			Desk_Debug_PrintMemory( Desk_jumpauto_newestbuf, sizeof( Desk_jump_buf));
			}
	#endif
	Desk_JumpAuto_Throw( (int) error);
	}

return	Desk_Error2_Exit( error);
} 


