]> khamidou — GitHub mirrors - electron.git/commitdiff
win: Add ELECTRON_DEFAULT_ERROR_MODE env
authorCheng Zhao <zcbenz@gmail.com>
Fri, 6 Nov 2015 10:51:34 +0000 (18:51 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 6 Nov 2015 12:25:20 +0000 (20:25 +0800)
It is useful to help debugging crashes without opening debugger.

atom/common/node_bindings.cc

index 10da202da70df9c366ead4ea1b543e8206b751d7..dbd0bd8d96ee1dc469ac5bb70cb58f7e4e4827c6 100644 (file)
@@ -14,6 +14,7 @@
 #include "atom/common/node_includes.h"
 #include "base/command_line.h"
 #include "base/base_paths.h"
+#include "base/environment.h"
 #include "base/files/file_path.h"
 #include "base/message_loop/message_loop.h"
 #include "base/path_service.h"
@@ -141,6 +142,14 @@ void NodeBindings::Initialize() {
   // Init node.
   // (we assume node::Init would not modify the parameters under embedded mode).
   node::Init(nullptr, nullptr, nullptr, nullptr);
+
+#if defined(OS_WIN)
+  // uv_init overrides error mode to suppress the default crash dialog, bring
+  // it back if user wants to show it.
+  scoped_ptr<base::Environment> env(base::Environment::Create());
+  if (env->HasVar("ELECTRON_DEFAULT_ERROR_MODE"))
+    SetErrorMode(0);
+#endif
 }
 
 node::Environment* NodeBindings::CreateEnvironment(