'use strict'
const {spawn} = require('child_process')
+const os = require('os')
const electron = require('electron')
const {app} = process.type === 'browser' ? electron : electron.remote
const binding = process.atomBinding('crash_reporter')
this.productName = options.productName
let {autoSubmit, companyName, extra, ignoreSystemCrashHandler, submitURL} = options
- this.tempDirectory = app.getPath('temp')
+ this.tempDirectory = getTempPath()
if (this.productName == null) {
this.productName = app.getName()
}
getUploadedReports () {
const productName = this.productName != null ? this.productName : app.getName()
- const tempDirectory = this.tempDirectory != null ? this.tempDirectory : app.getPath('temp')
+ const tempDirectory = this.tempDirectory != null ? this.tempDirectory : getTempPath()
return binding._getUploadedReports(productName, tempDirectory)
}
}
+const getTempPath = () => {
+ try {
+ return app.getPath('temp')
+ } catch (error) {
+ // app.getPath may throw so fallback to OS temp directory
+ return os.tmpdir()
+ }
+}
+
module.exports = new CrashReporter()