Fix Exceptions Always Being Printed

This commit fixes the issue, that exception messages were always printed
to cerr, regardless of SOL_PRINT_ERRORS setting. This also makes the
inclusion of iostream completely optional, reducing binary sizes.

Fixes #652.
This commit is contained in:
Alexander Hoischen 2018-06-11 21:07:33 +02:00 committed by The Phantom Derpstorm
parent ac709111e8
commit f0396f8e6b
2 changed files with 3 additions and 3 deletions

View File

@ -29,7 +29,7 @@
#include "function.hpp"
#include "object.hpp"
#ifdef SOL_PRINT_ERRORS
#if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS
#include <iostream>
#endif

View File

@ -29,7 +29,7 @@
#include <exception>
#include <cstring>
#ifdef SOL_PRINT_ERRORS
#if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS
#include <iostream>
#endif
@ -47,7 +47,7 @@ namespace sol {
// must push at least 1 object on the stack
inline int default_exception_handler(lua_State* L, optional<const std::exception&>, string_view what) {
#ifdef SOL_PRINT_ERRORS
#if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS
std::cerr << "[sol2] An exception occurred: ";
std::cerr.write(what.data(), what.size());
std::cerr << std::endl;