Skip to content

Commit

Permalink
fix(rpc/errorToObject): return null when error not present
Browse files Browse the repository at this point in the history
  • Loading branch information
CheerlessCloud committed Sep 28, 2018
1 parent 60005b6 commit 920ad4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/rpc/errorToObject.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @flow
export default function errorToObject(error: ?Error): void | Object {
export default function errorToObject(error: ?Error): null | Object {
const errorObj = {};

if (error === undefined) {
return undefined;
return null;
} else if (error === null) {
return undefined;
return null;
}

Object.getOwnPropertyNames(error).forEach(key => {
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/errorToObject.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import EError from 'eerror';
import errorToObject from './errorToObject';

test('call with undefined', t => {
t.is(errorToObject(undefined), undefined);
t.is(errorToObject(undefined), null);
});

test('call with null', t => {
t.is(errorToObject(null), undefined);
t.is(errorToObject(null), null);
});

test('call with eerror', t => {
Expand Down

0 comments on commit 920ad4f

Please sign in to comment.