/****************************************************************************** libx42pp - skinned vertex animation library (C++ API) Copyright (C) 2007 HermitWorks Entertainment Corporation 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 2 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, write to the Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA. ******************************************************************************/ #include "local.h" namespace x42 { static void X42_CALL def_warn_handler( int code, const char *msg ) { std::cerr << "Warning #" << code << ": " << msg << std::endl; } static void X42_CALL def_err_handler( int code, const char *msg ) { std::cerr << "Error #" << code << ": " << msg << std::endl; #if _CPPUNWIND throw error( code, msg ); #else #ifdef DEBUG __debugbreak(); #endif exit( code ); #endif } static StatusFunc onWarn = def_warn_handler; static StatusFunc onErr = def_err_handler; X42_EXPORT void X42_CALL SetWarningHandler( StatusFunc fn ) { onWarn = fn ? fn : def_warn_handler; } X42_EXPORT void X42_CALL SetErrorHandler( StatusFunc fn ) { onErr = fn ? fn : def_err_handler; } X42_EXPORT X42_NORETURN void X42_CALL fail( int code, const char *msg ) { onErr( code, msg ); } X42_EXPORT void X42_CALL warn( int code, const char *msg ) { onWarn( code, msg ); } };