Log a warning when a theme fails to load

Previously Atom would fail to launch if a theme referenced in
the config was not found.
This commit is contained in:
Kevin Sawicki 2013-08-09 11:24:21 -07:00
parent 136836e615
commit 7e04d85e1e
2 changed files with 12 additions and 1 deletions

View File

@ -23,3 +23,10 @@ describe "ThemeManager", ->
config.set('core.themes', [])
expect($('style.userTheme').length).toBe 0
describe "when a theme fails to load", ->
it "logs a warning", ->
themeManager = new ThemeManager()
spyOn(console, 'warn')
themeManager.loadTheme('a-theme-that-will-not-be-found')
expect(console.warn).toHaveBeenCalled()

View File

@ -27,7 +27,11 @@ class ThemeManager
@loadTheme(themeName) for themeName in themeNames
@loadUserStylesheet()
loadTheme: (name) -> @loadedThemes.push(new Theme(name))
loadTheme: (name) ->
try
@loadedThemes.push(new Theme(name))
catch error
console.warn("Failed to load theme #{name}", error.stack ? error)
getUserStylesheetPath: ->
stylesheetPath = fsUtils.resolve(path.join(config.configDirPath, 'user'), ['css', 'less'])