mirror of
https://github.com/atom/atom.git
synced 2026-02-15 09:05:58 -05:00
Log errors (instead of crashing) when the config file cannot be parsed
Also, config won't overwrite changes to config.cson when the file can not be parsed. Closes #401
This commit is contained in:
@@ -20,6 +20,7 @@ class Config
|
||||
userPackagesDirPath: userPackagesDirPath
|
||||
defaultSettings: null
|
||||
settings: null
|
||||
configFileHasErrors: null
|
||||
|
||||
constructor: ->
|
||||
@defaultSettings =
|
||||
@@ -55,8 +56,13 @@ class Config
|
||||
|
||||
loadUserConfig: ->
|
||||
if fs.exists(@configFilePath)
|
||||
userConfig = fs.readObject(@configFilePath)
|
||||
_.extend(@settings, userConfig)
|
||||
try
|
||||
userConfig = fs.readObject(@configFilePath)
|
||||
_.extend(@settings, userConfig)
|
||||
catch e
|
||||
@configFileHasErrors = true
|
||||
console.error "Failed to load user config '#{@configFilePath}'", e.message
|
||||
console.error e.stack
|
||||
|
||||
get: (keyPath) ->
|
||||
_.valueForKeyPath(@settings, keyPath) ?
|
||||
@@ -92,6 +98,7 @@ class Config
|
||||
subscription
|
||||
|
||||
update: ->
|
||||
return if @configFileHasErrors
|
||||
@save()
|
||||
@trigger 'updated'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user