RootView serialize absorbs exceptions when serializing extensions

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-06-14 11:20:16 -06:00
parent 291886b4b3
commit 810b9849ee
2 changed files with 25 additions and 2 deletions

View File

@@ -111,6 +111,27 @@ describe "RootView", ->
expect(rootView.editors().length).toBe 0
expect(document.title).toBe 'untitled'
describe ".serialize()", ->
it "absorbs exceptions that are thrown by extension serialize methods", ->
spyOn(console, 'error')
rootView.activateExtension(
name: "bad-egg"
activate: ->
serialize: -> throw new Error("I'm broken")
)
rootView.activateExtension(
name: "good-egg"
activate: ->
serialize: -> "I still get called"
)
data = rootView.serialize()
expect(data.extensionStates['good-egg']).toBe "I still get called"
expect(data.extensionStates['bad-egg']).toBeUndefined()
expect(console.error).toHaveBeenCalled()
describe "focus", ->
it "can receive focus if there is no active editor, but otherwise hands off focus to the active editor", ->
rootView = new RootView(require.resolve 'fixtures')

View File

@@ -66,8 +66,10 @@ class RootView extends View
serializeExtensions: ->
extensionStates = {}
for name, extension of @extensions
extensionStates[name] = extension.serialize?()
try
extensionStates[name] = extension.serialize?()
catch e
console?.error("Exception serializing '#{name}' extension", e)
extensionStates
deserializeView: (viewState) ->