]> khamidou — GitHub mirrors - electron.git/commitdiff
Unify how we throw exceptions
authorCheng Zhao <zcbenz@gmail.com>
Thu, 26 Mar 2015 03:34:41 +0000 (11:34 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 26 Mar 2015 03:34:41 +0000 (11:34 +0800)
atom/browser/api/atom_api_screen.cc
atom/browser/api/atom_api_window.cc

index 6e5dd716d7fd20d5210409e606821ede0919ad47..c595f350d9202e4bfb4ff0ee1a801a0a74497749 100644 (file)
@@ -117,16 +117,14 @@ mate::ObjectTemplateBuilder Screen::GetObjectTemplateBuilder(
 // static
 v8::Handle<v8::Value> Screen::Create(v8::Isolate* isolate) {
   if (!Browser::Get()->is_ready()) {
-    isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
-        isolate, "Can not initialize \"screen\" module before app is ready")));
-    return v8::Undefined(isolate);
+    node::ThrowError("Cannot initialize \"screen\" module before app is ready");
+    return v8::Null(isolate);
   }
 
   gfx::Screen* screen = gfx::Screen::GetNativeScreen();
   if (!screen) {
-    isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
-        isolate, "Failed to get screen information")));
-    return v8::Undefined(isolate);
+    node::ThrowError("Failed to get screen information");
+    return v8::Null(isolate);
   }
 
   return mate::CreateHandle(isolate, new Screen(screen)).ToV8();
index d8e18854c7446013acc9a191ef8d7295b3865e1c..ce9f584f74a6bd33a4f3a58512da6cb2a739dce6 100644 (file)
@@ -142,13 +142,11 @@ void Window::OnRendererResponsive() {
 // static
 mate::Wrappable* Window::New(v8::Isolate* isolate,
                              const mate::Dictionary& options) {
-  if (Browser::Get()->is_ready()) {
-    return new Window(options);
-  } else {
-    isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8(
-        isolate, "Can not create BrowserWindow before app is ready")));
+  if (!Browser::Get()->is_ready()) {
+    node::ThrowError("Cannot create BrowserWindow before app is ready");
     return nullptr;
   }
+  return new Window(options);
 }
 
 void Window::Destroy() {