Skip to content

Fix panic error when file is not found#51

Merged
aligator merged 2 commits intoaligator:masterfrom
fayccal:panic_fix
Feb 10, 2022
Merged

Fix panic error when file is not found#51
aligator merged 2 commits intoaligator:masterfrom
fayccal:panic_fix

Conversation

@fayccal
Copy link
Contributor

@fayccal fayccal commented Feb 9, 2022

I added a condition to check if the file exist and exit if it doesn't.

Copy link
Owner

@aligator aligator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you for contributing :-)

Your way works, but I would prefer to check that in the reader/reader.go
Sorry for not describing that more exactly in the issue description...

However, there you can check for file existence in the Read method and then just return the os.ErrNotExist error in case it doesn't.

That should then automatically be catched by the "error while processing file:" catch.

That way we avoid file-loading specific logic inside of the main.go.

@fayccal
Copy link
Contributor Author

fayccal commented Feb 10, 2022

Thanks you for your review,
Your right it is a better way to do this, i will apply the changes with what you said :)

Copy link
Owner

@aligator aligator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thank you!

@aligator aligator merged commit 31bbbee into aligator:master Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants