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

sqlState is not working anymore for PostgreSQL #331

Closed
mobiletoly opened this issue Jun 29, 2018 · 1 comment
Closed

sqlState is not working anymore for PostgreSQL #331

mobiletoly opened this issue Jun 29, 2018 · 1 comment

Comments

@mobiletoly
Copy link

mobiletoly commented Jun 29, 2018

This code used to report sqlState correctly in version 0.10.2 for PostgreSQL database. Now it is broken in 0.10.3

   try {
        Listings.insert {
            it[Listings.id] = listing.id
            it[Listings.providerUserId] = listing.providerUserId
            ...
        }
    } catch (ex: ExposedSQLException) {
        throw when (ex.sqlState) {
            "23505" -> RequestedListingAlreadyExistsException(listingId = listing.id)
            else -> ex
        }
    }

in case when Listings.id violates a constraint (duplicate). Now ex.sqlState is always null (as well as ex.errorCode is 0).

@Tapac
Copy link
Contributor

Tapac commented Jun 29, 2018

Now ExposedSQLException will delegate its sqlState and errorCode to an original exception if it was an instance of SQLException.

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

No branches or pull requests

2 participants