Unify how we throw exceptions
This commit is contained in:
parent
1a6677bdc3
commit
a4342fd5ba
2 changed files with 7 additions and 11 deletions
|
@ -117,16 +117,14 @@ mate::ObjectTemplateBuilder Screen::GetObjectTemplateBuilder(
|
||||||
// static
|
// static
|
||||||
v8::Handle<v8::Value> Screen::Create(v8::Isolate* isolate) {
|
v8::Handle<v8::Value> Screen::Create(v8::Isolate* isolate) {
|
||||||
if (!Browser::Get()->is_ready()) {
|
if (!Browser::Get()->is_ready()) {
|
||||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
node::ThrowError("Cannot initialize \"screen\" module before app is ready");
|
||||||
isolate, "Can not initialize \"screen\" module before app is ready")));
|
return v8::Null(isolate);
|
||||||
return v8::Undefined(isolate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
|
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
|
||||||
if (!screen) {
|
if (!screen) {
|
||||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
node::ThrowError("Failed to get screen information");
|
||||||
isolate, "Failed to get screen information")));
|
return v8::Null(isolate);
|
||||||
return v8::Undefined(isolate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mate::CreateHandle(isolate, new Screen(screen)).ToV8();
|
return mate::CreateHandle(isolate, new Screen(screen)).ToV8();
|
||||||
|
|
|
@ -142,13 +142,11 @@ void Window::OnRendererResponsive() {
|
||||||
// static
|
// static
|
||||||
mate::Wrappable* Window::New(v8::Isolate* isolate,
|
mate::Wrappable* Window::New(v8::Isolate* isolate,
|
||||||
const mate::Dictionary& options) {
|
const mate::Dictionary& options) {
|
||||||
if (Browser::Get()->is_ready()) {
|
if (!Browser::Get()->is_ready()) {
|
||||||
return new Window(options);
|
node::ThrowError("Cannot create BrowserWindow before app is ready");
|
||||||
} else {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8(
|
|
||||||
isolate, "Can not create BrowserWindow before app is ready")));
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
return new Window(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::Destroy() {
|
void Window::Destroy() {
|
||||||
|
|
Loading…
Reference in a new issue