mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
chore: add error throwing utility (#19803)
* chore: add error throwing utility * feedback from review * DRY out repeated isolate calls
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "base/values.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "shell/browser/api/event_emitter.h"
|
||||
#include "shell/common/error_util.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@@ -95,7 +96,8 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
void RemoveUserDefault(const std::string& name);
|
||||
bool IsSwipeTrackingFromScrollEventsEnabled();
|
||||
|
||||
std::string GetSystemColor(const std::string& color, mate::Arguments* args);
|
||||
std::string GetSystemColor(util::ErrorThrower thrower,
|
||||
const std::string& color);
|
||||
|
||||
bool CanPromptTouchID();
|
||||
v8::Local<v8::Promise> PromptTouchID(v8::Isolate* isolate,
|
||||
|
||||
@@ -405,8 +405,8 @@ std::string SystemPreferences::GetAccentColor() {
|
||||
return base::SysNSStringToUTF8([sysColor RGBAValue]);
|
||||
}
|
||||
|
||||
std::string SystemPreferences::GetSystemColor(const std::string& color,
|
||||
mate::Arguments* args) {
|
||||
std::string SystemPreferences::GetSystemColor(util::ErrorThrower thrower,
|
||||
const std::string& color) {
|
||||
NSColor* sysColor = nil;
|
||||
if (color == "blue") {
|
||||
sysColor = [NSColor systemBlueColor];
|
||||
@@ -427,7 +427,7 @@ std::string SystemPreferences::GetSystemColor(const std::string& color,
|
||||
} else if (color == "yellow") {
|
||||
sysColor = [NSColor systemYellowColor];
|
||||
} else {
|
||||
args->ThrowError("Unknown system color: " + color);
|
||||
thrower.ThrowError("Unknown system color: " + color);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user