endExternalEditor(error, result) { this.rl.resume(); if (error) { this.editorResult.error(error); } else { this.editorResult.next(result); } }
it('uses the error handler', () => { spyOn(atom.notifications, 'addError'); const handleError = jasmine.createSpy('handleError'); const messages = new Subject(); const logTailer = new LogTailer({ name: 'test', messages, handleError, trackingEvents: { start: 'logtailer-test-start', stop: 'logtailer-test-stop', restart: 'logtailer-test-restart', }, }); logTailer.start(); messages.error(new Error('Uh oh')); expect(handleError).toHaveBeenCalled(); expect(atom.notifications.addError).not.toHaveBeenCalled(); });
it("doesn't use the default notification when the error handler throws a new error", () => { spyOn(atom.notifications, 'addError'); const handleError = jasmine.createSpy('handleError') .andCallFake(() => { throw new Error('Unexpected'); }); const messages = new Subject(); const logTailer = new LogTailer({ name: 'test', messages, handleError, trackingEvents: { start: 'logtailer-test-start', stop: 'logtailer-test-stop', restart: 'logtailer-test-restart', }, }); logTailer.start(); messages.error(new Error('Uh oh')); expect(handleError).toHaveBeenCalled(); expect(atom.notifications.addError).not.toHaveBeenCalled(); });
it("shows an error notification when a running callback isn't registered", () => { spyOn(atom.notifications, 'addError'); const ready = new Subject(); const messages = new Subject(); const err = new Error('Uh oh'); const logTailer = new LogTailer({ name: 'test', messages, ready, trackingEvents: { start: 'logtailer-test-start', stop: 'logtailer-test-stop', restart: 'logtailer-test-restart', }, }); const handleRunning = jasmine.createSpy(); logTailer.start({onRunning: handleRunning}); logTailer.start(); messages.error(err); expect(handleRunning).toHaveBeenCalledWith(err); expect(atom.notifications.addError).toHaveBeenCalled(); });
error => { data$.error(error); },