Simplify SerdeError - #1458
Conversation
3005e70 to
c5f6189
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1458 +/- ##
==========================================
+ Coverage 92.11% 92.12% +0.01%
==========================================
Files 40 40
Lines 18026 18000 -26
==========================================
- Hits 16604 16583 -21
+ Misses 1422 1417 -5 ☔ View full report in Codecov by Sentry. |
| } | ||
|
|
||
| /// Create a custom `de::Error` with `SerdeError::InvalidTimestamp`. | ||
| pub(crate) fn invalid_ts<E, T>(value: T) -> E |
There was a problem hiding this comment.
Three suggestions:
- Maybe this function should be attached to
SerdeErroras a sort of (not quite) constructor, likeSerdeError::invalid()? - (If not, this function should be defined above
SerdeError) - Let's move this into the
crate::serdeinline module inlib.rs?
There was a problem hiding this comment.
Maybe this function should be attached to
SerdeErroras a sort of (not quite) constructor, likeSerdeError::invalid()?(If not, this function should be defined above
SerdeError)
In my defence, that function looked very different when I started 😆. But I'll keep trying to put things in that order.
I like that with a standalone function only invalid_ts is public (within the crate), with the type just an implementation detail.
- Let's move this into the
crate::serdeinline module inlib.rs?
Good suggestion, much more logical place. I added the move as an initial commit.
c5f6189 to
bc03a0f
Compare
While investigating all the CI failures on #1454 I noticed our serde code tries to convert
LocalResults to a custom error type.This can all be done in a much simpler way.
I did keep around a simple error enum because it allows reporting the invalid value.
It currently has only one variant for deserialization errors for UNIX timestamps. We could simplify it further, or leave room for adding more formats to deserialize.
Also included is the fix from #1396 for an invalid cast in the
ts_secondsmodule forNaiveDateTime.