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

    File:    Error3.c
    Author:  Copyright  1995 Julian Smith
    Version: 1.00 (07 Sep 1995)
    Purpose: Error handling
*/


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


Desk_error2_handler	Desk_error2__handlerfn	= NULL;

#ifdef _DLL
Desk_error2_handler*	Desk_Error2__Ref__handlerfn( void)	{ return &Desk_error2__handlerfn;	}
#endif



void	Desk_Error2_Handle( Desk_error2_block *error)
{
Desk_Debug_Printf( Desk_error_PLACE "\n");
Desk_Debug_Printf( Desk_error_PLACE "Desk_Error2_Handle called for Desk_error2_block at 0x%p\n", error);
Desk_Debug_DescribeError2( error);
#ifdef Desk_DEBUG
	Desk_BackTrace_OutputToFFunctionWithPrefix( Desk_Debug_PrintfRef, NULL, Desk_error_PLACE);
#endif

if ( Desk_error2__handlerfn)	{
	Desk_Debug_Printf( Desk_error_PLACE "Calling Desk_error2__handlerfn 0x%p\n", Desk_error2__handlerfn);
	Desk_error2__handlerfn( error);
	}
else	{
	Desk_Debug_Printf( Desk_error_PLACE "Desk_error2__handlerfn = NULL, so calling Desk_Error2_Exit\n");
	Desk_Error2_Exit( error);
	}
/* If handlerfn returns, it wil have solved the problem...	*/
}


void	Desk_Error2_ClearErrorBlock( Desk_error2_block *error)
{
error->type		= Desk_error2_type_NONE;
error->data.misc	= NULL;
}
