Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginDebug.cpp

Issue 5137721374801920: Issue #1173 - Default behavior for catch-all blocks
Patch Set: add arguments for templates, add logging default function Created March 2, 2015, 5:02 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/PluginDebug.cpp
===================================================================
--- a/src/plugin/PluginDebug.cpp
+++ b/src/plugin/PluginDebug.cpp
@@ -16,11 +16,53 @@
*/
#include "PluginStdAfx.h"
-
#include "PluginDebug.h"
+#include "Exception.h"
#include "PluginMutex.h"
#include "PluginSettings.h"
+#if (defined ENABLE_DEBUG_INFO)
+struct EntryPointHandlers
+{
+ static void Unknown(std::string name)
+ {
+ CPluginDebug::Debug("Unknown exception in catch-all for entry point " + name);
+ }
+ static void Exception(std::exception& ex, std::string name)
+ {
+ CPluginDebug::DebugOrdinaryException(ex,
+ PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION,
+ "std::exception in catch-all for entry point " + name);
+ }
+ static void LogicError(std::logic_error& ex, std::string name)
+ {
+ CPluginDebug::DebugOrdinaryException(ex,
+ PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION,
+ "std::logic_error in catch-all for entry point " + name);
+ }
+ static void RuntimeError(std::runtime_error& ex, std::string name)
+ {
+ CPluginDebug::DebugOrdinaryException(ex,
+ PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION,
+ "std::runtime_error in catch-all for entry point " + name);
+ }
+ static void SystemError(std::system_error& ex, std::string name)
+ {
+ CPluginDebug::DebugSystemException(ex,
+ PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION,
+ "std::system_error in catch-all for entry point " + name);
+ }
+};
+#endif
+
+void EntryPointExceptionDefault(std::string name)
Oleksandr 2015/03/05 07:18:55 I'd prefer 'DefaultExceptionHander' instead. This
Eric 2015/03/05 14:58:04 As a small point of language, there's no need to u
+{
+#if (defined ENABLE_DEBUG_INFO)
+ CatchAllVoid<EntryPointHandlers>::Handler(name);
+#endif
+}
+
+
class CPluginDebugLock : public CPluginMutex
{
@@ -49,6 +91,14 @@
DEBUG_ERROR_LOG(ex.code().value(), errorId, errorSubid, message);
}
+void CPluginDebug::DebugOrdinaryException(const std::exception& ex, int errorId, int errorSubid, const std::string& description)
+{
+ std::string message = description + ", " + ex.what();
+ DEBUG_ERROR_LOG(0, errorId, errorSubid, message);
+}
+
+
+
#ifdef ENABLE_DEBUG_INFO
void DebugLegacy(const CString& text, DWORD dwProcessId, DWORD dwThreadId)

Powered by Google App Engine
This is Rietveld