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

Refactor error classes #15

Merged
merged 5 commits into from
Jan 13, 2023

Commits on Jan 11, 2023

  1. Refactor error classes

    Fix: trilogy-libraries#11
    
    The goals are:
    
      - Not raise any error that isn't a descendant of `Trilogy::Error`.
      - Have a clear distinction between transient network errors that may be retried, and invalid queries that shouldn't.
    
    Unsolved issues (yet)
    
      - Trilogy calls `rb_syserr_fail_str` in a few places. Meaning it can still raise any of the `Errno::*` errors.
      - `handle_trilogy_error` raise all `TRILOGY_ERR` as `ProtocolError` which is a `ConnectionError`, but
         I'm not certain none of the possible errors could be considered client errors.
    byroot authored and adrianna-chang-shopify committed Jan 11, 2023
    Configuration menu
    Copy the full SHA
    a78b0cb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9db5431 View commit details
    Browse the repository at this point in the history
  3. Trilogy::ProtocolError should use SQL codes to determine error class

    Instead of raising all ProtocolErrors as connection errors,
    we use the SQL error code to determine the type of error to raise
    when handling the Trilogy error in the Ruby bindings.
    
    The mapping of error codes to error classes was taken from the mysql2
    implementation: https://github.com/brianmario/mysql2/blob/master/lib/mysql2/error.rb#L13-L27
    
    Note that we don't need to care about the 2xxx errors because those
    are raised by the libmysql client, which Trilogy doesn't deal with.
    
    Co-authored-by: Jean Boussier <jean.boussier@shopify.com>
    adrianna-chang-shopify and byroot committed Jan 11, 2023
    Configuration menu
    Copy the full SHA
    f9ee855 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c56494e View commit details
    Browse the repository at this point in the history

Commits on Jan 13, 2023

  1. Fix test_timeout_error

    byroot committed Jan 13, 2023
    Configuration menu
    Copy the full SHA
    1a9ab90 View commit details
    Browse the repository at this point in the history