You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Push function in BytesQueue currently uses a generic error message when the queue is full. It is suggested to use errFullQueue for a more descriptive error message.
Current Code:
var (
errEmptyQueue=&queueError{"Empty queue"}
errInvalidIndex=&queueError{"Index must be greater than zero. Invalid index."}
errIndexOutOfBounds=&queueError{"Index out of range"}
)
var (
errEmptyQueue=&queueError{"Queue is empty."}
errInvalidIndex=&queueError{"Index must be greater than zero. Invalid index."}
errIndexOutOfBounds=&queueError{"Index out of range."}
errFullQueue=&queueError{"Queue is full. Maximum size limit reached."}
)
The text was updated successfully, but these errors were encountered:
akanchha25
changed the title
Improve error handling in BytesQueue.Push function by using descriptive error messages in queue.go
Improve error handling in BytesQueue.Push function in queue.go
Jul 13, 2024
@akanchha25 Indeed it's a good improvement. Do you think errors should be unexpeorted? If we export them then they could be used to check for given error like with io.EOF
@janisz That's a great point. Exporting the errors would indeed allow for more robust error handling, similar to checking for specific errors like io.EOF. This could be beneficial for users of the BytesQueue package to handle different error scenarios more explicitly.
I can update the code to export these error variables, making it easier for others to handle specific error conditions. I'll proceed with the changes if that sounds good to you.
Hi @akanchha25@janisz . Guys i think bundling and seperating all error logs in a different go file like bytes_queue_error_logs.go would make it easy for us to keep all error logs in a single place and then export them directly in different functions or files for queue package. Would love to know your thoughts on this and if required, would like to work on adding this functionality if you could assign me this task.
The Push function in BytesQueue currently uses a generic error message when the queue is full. It is suggested to use errFullQueue for a more descriptive error message.
Current Code:
Push function
Updated code
This will improve the code quality
The text was updated successfully, but these errors were encountered: