Browse Source

fix: throw better error on getPath('logs') (#19514) (#19545)

Shelley Vohr 5 years ago
parent
commit
fa4a26a1db
2 changed files with 10 additions and 3 deletions
  1. 9 2
      atom/browser/api/atom_api_app.cc
  2. 1 1
      docs/api/app.md

+ 9 - 2
atom/browser/api/atom_api_app.cc

@@ -860,8 +860,15 @@ base::FilePath App::GetPath(mate::Arguments* args, const std::string& name) {
   int key = GetPathConstant(name);
   if (key >= 0)
     succeed = base::PathService::Get(key, &path);
-  if (!succeed)
-    args->ThrowError("Failed to get '" + name + "' path");
+  if (!succeed) {
+    if (name == "logs") {
+      args->ThrowError("Failed to get '" + name +
+                       "' path: setAppLogsPath() must be called first.");
+    } else {
+      args->ThrowError("Failed to get '" + name + "' path");
+    }
+  }
+
   return path;
 }
 

+ 1 - 1
docs/api/app.md

@@ -578,7 +578,7 @@ them.
 
 Sets or creates a directory your app's logs which can then be manipulated with `app.getPath()` or `app.setPath(pathName, newPath)`.
 
-On _macOS_, this directory will be set by deafault to `/Library/Logs/YourAppName`, and on _Linux_ and _Windows_ it will be placed inside your `userData` directory.
+Calling `app.setAppLogsPath()` without a `path` parameter will result in this directory being set to `/Library/Logs/YourAppName` on _macOS_, and inside the `userData` directory on _Linux_ and _Windows_.
 
 ### `app.getAppPath()`