-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expect a message
property at a minimum to be interpreted as an Error
#77
Expect a message
property at a minimum to be interpreted as an Error
#77
Conversation
test('should deserialize error', t => { | ||
const deserialized = deserializeError(new Error('test')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was not testing deserialization
test('should deserialize error', t => { | ||
const deserialized = deserializeError(new Error('test')); | ||
const deserialized = deserializeError({ | ||
message: 'Stuff happened', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new minimum viable serialized object
@@ -169,10 +169,23 @@ test('should deserialize array', t => { | |||
deserializeNonError(t, [1]); | |||
}); | |||
|
|||
test('should deserialize empty object', t => { | |||
deserializeNonError(t, {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serializeError({})
was deserialized as new Error('')
, now it throws a NonError
index.js
Outdated
@@ -78,7 +78,7 @@ const destroyCircular = ({ | |||
from: value, | |||
seen: [...seen], | |||
|
|||
to_: isErrorLike(value) ? new Error() : undefined, | |||
to_: isMinimumViableSerializedError(value) ? new Error() : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the inconsistent expectation between the minimum viable error at the top level and for nested errors.
{}
was deserialized as an error{cause: {name: 'Error', message: 'foo'}
was serialized as an error, butcause
wasn't
After #73 this check should also be changed in the new code there.
message
property at a minimum to be interpreted as an Error
I think the docs should explicitly mention what we consider an error when deserializing: https://github.com/sindresorhus/serialize-error#deserializeerrorvalue-options |
By the way this is another breaking change, technically, because: deserializeError({stuffHappened: "details"})
- // => new Error('') with 'stuffHappened' property
+ // => new NonError('{"stuffHappened": "details"}') |
Can you fix the merge conflict? |
No description provided.