Skip to content
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

Avoid throwing OffsetNotFoundException in StreamSystem.QueryOffset(string, string) #370

Open
bangjiehan opened this issue Mar 20, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bangjiehan
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I think only when there indeed is something wrong does C# throw a exception. Or at least there is some way to check before, for example call File.Exists before calling File.Read~.
There seems no way to check whether Offset exist or not before calling QueryOffset.

Describe the solution you'd like

Add one of the following overloads or modify current implementation of QueryOffset.

bool exist = StreamSystem.TryQueryOffset(string, string, out ulong offset)
ulong? offset = StreamSystem.TryQueryOffset(string, string)

Describe alternatives you've considered

No response

Additional context

No response

@bangjiehan bangjiehan added the enhancement New feature or request label Mar 20, 2024
@bangjiehan bangjiehan changed the title Avoid thrown OffsetNotFoundException in StreamSystem.QueryOffset(string, string) Avoid throwing OffsetNotFoundException in StreamSystem.QueryOffset(string, string) Mar 20, 2024
@Gsantomaggio
Copy link
Member

Thank you @bangjiehan
I think you are right.

We can add bool exist = StreamSystem.TryQueryOffset(string, string, out ulong offset) (it is more idiomatic)

The important thing is to keep the current implementation. We could mark it as deprecated and remove it on 2.0

@lukebakken lukebakken self-assigned this Mar 20, 2024
@lukebakken lukebakken added this to the 2.0.0 milestone Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants