Catch and log errors parsing window state

Previously if a read or parse error occurred the window
would never show and the dev tools would be inaccessible.
This commit is contained in:
Kevin Sawicki
2013-06-03 12:14:17 -07:00
parent 7f0947ef9b
commit f3a500923c

View File

@@ -241,9 +241,15 @@ window.atom =
windowState
getWindowState: (keyPath) ->
return {} unless fsUtils.exists(@getWindowStatePath())
windowStatePath = @getWindowStatePath()
return {} unless fsUtils.exists(windowStatePath)
try
windowState = JSON.parse(fsUtils.read(windowStatePath) or '{}')
catch error
console.warn "Error parsing window state: #{windowStatePath}", error.stack, error
windowState = {}
windowState = JSON.parse(fsUtils.read(@getWindowStatePath()) or '{}')
if keyPath
_.valueForKeyPath(windowState, keyPath)
else