]> khamidou — GitHub mirrors - electron.git/commitdiff
Throw error when PathService call failed
authorCheng Zhao <zcbenz@gmail.com>
Mon, 19 Jan 2015 04:24:58 +0000 (20:24 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 19 Jan 2015 05:43:21 +0000 (21:43 -0800)
atom/browser/api/atom_api_app.cc
atom/browser/api/atom_api_app.h
vendor/brightray

index 884c3d90a0ce7b856334627040bfa3a255ecc147..440795831ae44e19ce3eea69a64a97a860caa11e 100644 (file)
@@ -151,18 +151,26 @@ void App::OnFinishLaunching() {
   Emit("ready");
 }
 
-base::FilePath App::GetPath(const std::string& name) {
+base::FilePath App::GetPath(mate::Arguments* args, const std::string& name) {
+  bool succeed = false;
   base::FilePath path;
   int key = GetPathConstant(name);
   if (key >= 0)
-    PathService::Get(key, &path);
+    succeed = PathService::Get(key, &path);
+  if (!succeed)
+    args->ThrowError("Failed to get path");
   return path;
 }
 
-void App::SetPath(const std::string& name, const base::FilePath& path) {
+void App::SetPath(mate::Arguments* args,
+                  const std::string& name,
+                  const base::FilePath& path) {
+  bool succeed = false;
   int key = GetPathConstant(name);
   if (key >= 0)
-    PathService::Override(key, path);
+    succeed = PathService::Override(key, path);
+  if (!succeed)
+    args->ThrowError("Failed to set path");
 }
 
 void App::ResolveProxy(const GURL& url, ResolveProxyCallback callback) {
index 9b67cb5b717356570462b128c0f92e3557614125..41a820b7a765751a92df4d0d5953bef0065345e8 100644 (file)
@@ -18,6 +18,10 @@ namespace base {
 class FilePath;
 }
 
+namespace mate {
+class Arguments;
+}
+
 namespace atom {
 
 namespace api {
@@ -49,11 +53,11 @@ class App : public mate::EventEmitter,
 
  private:
   // Get/Set the pre-defined path in PathService.
-  base::FilePath GetPath(const std::string& name);
-  void SetPath(const std::string& name, const base::FilePath& path);
+  base::FilePath GetPath(mate::Arguments* args, const std::string& name);
+  void SetPath(mate::Arguments* args,
+               const std::string& name,
+               const base::FilePath& path);
 
-  void SetDataPath(const base::FilePath& path);
-  base::FilePath GetDataPath();
   void ResolveProxy(const GURL& url, ResolveProxyCallback callback);
   void SetDesktopName(const std::string& desktop_name);
 
index 8eb714dac77e3d3fd43fba76c835d29b838cc8be..f19c269ab974f22f31782c0c395119130fb59b15 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 8eb714dac77e3d3fd43fba76c835d29b838cc8be
+Subproject commit f19c269ab974f22f31782c0c395119130fb59b15