Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit af23291

Browse files
committed
refactor(core): throw error in serializeSync
Ref #549 (comment)
1 parent d6d749f commit af23291

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

packages/core/lib/fury.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,7 @@ class Fury {
267267
const adapter = findAdapter(this.adapters, mediaType, 'serialize');
268268

269269
if (!adapter) {
270-
// eslint-disable-next-line no-console
271-
console.warn('Media type did not match any registered serializer!');
272-
273-
return null;
270+
throw new Error('Media type did not match any registered serializer!');
274271
}
275272

276273
if (!api) {

packages/core/test/serialize-test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ describe('Serialize', () => {
110110
});
111111

112112
describe('using serializeSync', () => {
113-
it('returns null with unknown mediaType', () => {
113+
it('errors with unknown mediaType', () => {
114114
const fury = new Fury();
115115
const api = new fury.minim.elements.Category();
116116

117-
const result = fury.serializeSync({ api, mediaType: 'application/unregistered' });
118-
expect(result).to.equal(null);
117+
expect(() => {
118+
fury.serializeSync({ api, mediaType: 'application/unregistered' });
119+
}).to.throw('Media type did not match any registered serializer!');
119120
});
120121

121122
it('can serialize with matching adapter', async () => {

0 commit comments

Comments
 (0)