-
Notifications
You must be signed in to change notification settings - Fork 3
Lyh data store #4
base: dev
Are you sure you want to change the base?
Conversation
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.
Combining multiple statements is error-prone and difficult to refactor.
Say function f1
, f2
and f3
Good Practice
foo := f1()
bar := f2()
zoo := f3(foo, bar)
Bad Practice
zoo := f3(
f1(), f2())
vendor/abcdb/storage/data_store.go
Outdated
} | ||
SimpleStream.RecordList = append(SimpleStream.RecordList, record) | ||
} | ||
if errcount != 0 { |
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.
contract: return (nil, error) in failure.
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.
BTW, you "hide" the error message in your codes.
Just stop your codes and "throw" the error when the very FIRST error occurs.
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.
BTW, you "hide" the error message in your codes.
Just stop your codes and "throw" the error when the very FIRST error occurs.
My thought was to track and skip the records which can't be deserialized, and return other good records...
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.
BTW, you "hide" the error message in your codes.
Just stop your codes and "throw" the error when the very FIRST error occurs.My thought was to track and skip the records which can't be deserialized, and return other good records...
When an error occurs,
- If you believe you can handle it, do so.
- If you are unable(or not responsible) to handle it, return the error. Let other ones to handle it.
Generally, Deserialize
should be perfectly successful. If it failed, you do not know how to handle it.
No description provided.