diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index e3a1f401f..15ad1f0f4 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -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') diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index ee438fa59..8f4356535 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -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) ->