| LEFT | RIGHT |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 #include "PluginStdAfx.h" | 18 #include "PluginStdAfx.h" |
| 19 |
| 19 #include "PluginDebug.h" | 20 #include "PluginDebug.h" |
| 20 #include "Exception.h" | 21 #include "Exception.h" |
| 21 #include "PluginMutex.h" | 22 #include "PluginMutex.h" |
| 22 #include "PluginSettings.h" | 23 #include "PluginSettings.h" |
| 23 | 24 |
| 24 #if (defined ENABLE_DEBUG_INFO) | 25 #if (defined ENABLE_DEBUG_INFO) |
| 25 namespace { | 26 namespace { |
| 26 // VS 2012 does not have support for variadic templates, which would eliminate
the need for an argument class. | 27 // VS 2012 does not have support for variadic templates, which would eliminate
the need for an argument class. |
| 27 struct LogHandlersArguments | 28 struct LogHandlersArguments |
| 28 { | 29 { |
| 29 bool isEntryPoint; | 30 bool isEntryPoint; |
| 30 std::string name; | 31 std::string name; |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 std::string DefaultLogMessage(const LogHandlersArguments& x, const std::string
&exceptionType) | 34 std::string DefaultLogMessage(const LogHandlersArguments& x, const std::string
&exceptionType) |
| 34 { | 35 { |
| 35 std::string s = x.isEntryPoint ? "ENTRY POINT '" : "'"; | 36 std::string s = x.isEntryPoint ? "ENTRY POINT '" : "'"; |
| 36 s += x.name; | 37 s += x.name; |
| 37 s += "' caught default "; | 38 s += "' caught default "; |
| 38 s += exceptionType; | 39 s += exceptionType; |
| 39 return s; | 40 return s; |
| 40 } | 41 } |
| 41 | 42 |
| 42 struct LogHandlers | 43 struct LogHandlers |
| 43 { | 44 { |
| 44 static void Unknown(const LogHandlersArguments& args) | 45 static void Unknown(const LogHandlersArguments& args) |
| 45 { | 46 { |
| 46 CPluginDebug::Debug(DefaultLogMessage(args, "Unknown exception")); | 47 CPluginDebug::Debug(DefaultLogMessage(args, "Unknown exception")); |
| 47 } | 48 } |
| 48 static void Exception(std::exception& ex, LogHandlersArguments& args) | 49 static void Exception(const std::exception& ex, LogHandlersArguments& args) |
| 49 { | 50 { |
| 50 CPluginDebug::DebugOrdinaryException(ex, | 51 CPluginDebug::DebugOrdinaryException(ex, |
| 51 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, | 52 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, |
| 52 DefaultLogMessage(args, "std::exception")); | 53 DefaultLogMessage(args, "std::exception")); |
| 53 } | 54 } |
| 54 static void LogicError(std::logic_error& ex, LogHandlersArguments& args) | 55 static void LogicError(const std::logic_error& ex, LogHandlersArguments& arg
s) |
| 55 { | 56 { |
| 56 CPluginDebug::DebugOrdinaryException(ex, | 57 CPluginDebug::DebugOrdinaryException(ex, |
| 57 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, | 58 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, |
| 58 DefaultLogMessage(args, "std::logic_error")); | 59 DefaultLogMessage(args, "std::logic_error")); |
| 59 } | 60 } |
| 60 static void RuntimeError(std::runtime_error& ex, LogHandlersArguments& args) | 61 static void RuntimeError(const std::runtime_error& ex, LogHandlersArguments&
args) |
| 61 { | 62 { |
| 62 CPluginDebug::DebugOrdinaryException(ex, | 63 CPluginDebug::DebugOrdinaryException(ex, |
| 63 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, | 64 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, |
| 64 DefaultLogMessage(args, "std::runtime_error")); | 65 DefaultLogMessage(args, "std::runtime_error")); |
| 65 } | 66 } |
| 66 static void SystemError(std::system_error& ex, LogHandlersArguments& args) | 67 static void SystemError(const std::system_error& ex, LogHandlersArguments& a
rgs) |
| 67 { | 68 { |
| 68 CPluginDebug::DebugSystemException(ex, | 69 CPluginDebug::DebugSystemException(ex, |
| 69 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, | 70 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, |
| 70 DefaultLogMessage(args, "std::std::system_error")); | 71 DefaultLogMessage(args, "std::std::system_error")); |
| 71 } | 72 } |
| 72 }; | 73 }; |
| 73 } | 74 } |
| 74 #endif | 75 #endif |
| 75 | 76 |
| 76 void EntryPointExceptionDefault(const std::string& name) | 77 void EntryPointExceptionDefault(const std::string& name) |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 srcTrunc = srcTrunc.Left(67) + L"..." + srcTrunc.Right(30); | 329 srcTrunc = srcTrunc.Left(67) + L"..." + srcTrunc.Right(30); |
| 329 } | 330 } |
| 330 | 331 |
| 331 CString blocking; | 332 CString blocking; |
| 332 blocking.Format(L"Ignored %-12s %s %s", ToCString(type), domain.empty()? L"
-" : ToCString(domain), srcTrunc); | 333 blocking.Format(L"Ignored %-12s %s %s", ToCString(type), domain.empty()? L"
-" : ToCString(domain), srcTrunc); |
| 333 | 334 |
| 334 DebugResultLegacy(blocking); | 335 DebugResultLegacy(blocking); |
| 335 } | 336 } |
| 336 | 337 |
| 337 #endif // ENABLE_DEBUG_RESULT_IGNORED | 338 #endif // ENABLE_DEBUG_RESULT_IGNORED |
| LEFT | RIGHT |