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

Add exception classes #110

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

brodyhoskins
Copy link

@brodyhoskins brodyhoskins commented Aug 22, 2023

Fixes #109

While I used different classes for the exceptions, I wanted to keep some level of backward-compatibility by retaining the existing error messages.

Copy link
Member

@bcardiff bcardiff left a comment

Choose a reason for hiding this comment

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

Sorry for the later review. I like the direction, but have some comments.

end

class UnexpectedPacketError < PacketError
getter :status
Copy link
Member

Choose a reason for hiding this comment

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

I would stick with getter status : UInt8 style

Copy link
Author

Choose a reason for hiding this comment

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

I'm admittedly inexperience with Crystal so I'll take the style advice, see 7fadad9.

class PacketError < ConnectionError
getter :packet

def initialize(packet : ReadPacket, message)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think ReadPacket should be exposed, it's an internal implementation detail.

Copy link
Author

Choose a reason for hiding this comment

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

Check out the changes on c14f4e6; I'm hoping it addresses your concern.

1. Remove `PacketError`
2. Make `UnexpectedPacketError` inherit from `Exception` rather than `PacketError`
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.

Generic Exceptions raised in MySql::Connection
2 participants