Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
An exception hierarchy corresponding to SQLSTATE codes from the SQL Standard.
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
script
test
.gitignore
History.txt
Manifest.txt
README.rdoc
Rakefile

README.rdoc

sqlstate

DESCRIPTION:

An exception hierarchy corresponding to SQLSTATE codes from the SQL Standard.

Most SQL platforms can return their error codes in the form of an SQLSTATE; this library ensures differing database drivers can all throw the same errors.

A common library reduces the temptation, when writing a database driver, to simply throw all possible errors using a single generic exception.

The primary intended audience is authors of database drivers; other users only interaction with this library should be in catching its exceptions.

FEATURES:

  • Exception hierarchy that maps to a good portion of the Standard's SQLSTATE codes

  • Ability to extend the hierarchy for a database platform, mixing vendor codes with Standard ones

  • Vendor-specific exception hierarchies for

    • PostgreSQL

SYNOPSIS:

require 'sqlstate'
raise SqlState.create('22012')  # Division By Zero

require 'sqlstate/postgres'
ex = SqlState::PostgresError.create('08P01')  # Protocol Violation
ex.hint = 'Try doing the right thing.'
raise ex

INSTALL:

[sudo] gem install sqlstate

LICENSE:

(The MIT License)

Copyright © 2009 Matthew Draper

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.