diff --git a/packages/netlify-cms-core/src/lib/__tests__/registry.spec.js b/packages/netlify-cms-core/src/lib/__tests__/registry.spec.js index 633025b9..d751d347 100644 --- a/packages/netlify-cms-core/src/lib/__tests__/registry.spec.js +++ b/packages/netlify-cms-core/src/lib/__tests__/registry.spec.js @@ -170,6 +170,19 @@ describe('registry', () => { expect(handler).toHaveBeenCalledTimes(2); expect(handler).toHaveBeenLastCalledWith(data, options2); }); + + it(`should throw error when '${name}' handler throws error`, async () => { + const { registerEventListener, invokeEvent } = require('../registry'); + + const handler = jest.fn(() => { + throw new Error('handler failed!'); + }); + + registerEventListener({ name, handler }); + const data = { entry: fromJS({ data: {} }) }; + + await expect(invokeEvent({ name, data })).rejects.toThrow('handler failed!'); + }); }); it(`should return an updated entry's DataMap`, async () => { diff --git a/packages/netlify-cms-core/src/lib/registry.js b/packages/netlify-cms-core/src/lib/registry.js index 1e56a1b9..534ccf50 100644 --- a/packages/netlify-cms-core/src/lib/registry.js +++ b/packages/netlify-cms-core/src/lib/registry.js @@ -246,14 +246,10 @@ export async function invokeEvent({ name, data }) { let _data = { ...data }; for (const { handler, options } of handlers) { - try { - const result = await handler(_data, options); - if (result !== undefined) { - const entry = _data.entry.set('data', result); - _data = { ...data, entry }; - } - } catch (e) { - console.warn(`Failed running handler for event ${name} with message: ${e.message}`); + const result = await handler(_data, options); + if (result !== undefined) { + const entry = _data.entry.set('data', result); + _data = { ...data, entry }; } } return _data.entry.get('data');