-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix issue 26 #27
Closed
Closed
fix issue 26 #27
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
80a0229
fix issue 26
chavacava b841c18
clearer test implementation
chavacava 0bdc91a
make it explicit here that we primarily intend this case for io.SeekEnd
chavacava 11ea917
check err in the deferred seek to initial pos
chavacava 3e00f49
Merge branch 'fix-26' of https://github.com/chavacava/kaitai_struct_g…
chavacava fc91f26
removes unnecessary trailing newline
chavacava File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't quite get why this check function is declared for each case individually. All cases use
failingReader
:kaitai_struct_go_runtime/kaitai/stream_test.go
Lines 151 to 153 in 3e00f49
which in turn always returns
artificialError
iffailingCondition
(also known asmustFail
) is true:kaitai_struct_go_runtime/kaitai/stream_test.go
Lines 91 to 93 in 3e00f49
So I'd rather replace
stream_test.go:159-161
with the previous version:kaitai_struct_go_runtime/kaitai/stream_test.go
Lines 114 to 117 in b841c18
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.
Not all cases return
artificialError
: when the deferred seek fails it returns anartificialError
wrapped into afmt.wrapError
.A more explicit definition could be:
Anyway, you can go ahead, pick the version you like the most and modify the PR consequently.
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.
Oh, thanks, I didn't notice that. I didn't see this little exclamation mark in
!ok
here:kaitai_struct_go_runtime/kaitai/stream_test.go
Lines 142 to 145 in fc91f26
The above "check" is totally unacceptable because it only checks that the
artificialError
is either wrapped somewhere inside or we're dealing with a completely different error that does not have anything in common withartificialError
at all. It is also deceptive because it looks so similar toreturn ok
, which would make more sense.But it turns out that the linter knows about the problem that wrapped errors cannot be simply type asserted, and it suggested a solution:
So I believe that this silver bullet
errors.As
should work for everything:See https://play.golang.org/p/1FN6BVmqRWV for a demo.