java - Gradle build unexpected behaviour vs IDE - Stack Overflow

I have the following code which executes spring DatabaseClient insert logic:suspend fun saveXXX(xxx: XX

I have the following code which executes spring DatabaseClient insert logic:

 suspend fun saveXXX(xxx: XXX): InsertStatus {
        return try {
            doSave(xxx)
            InsertStatus.INSERTED
        } catch (exception: DuplicateKeyException) {
            val errDetails = (exception.cause as PostgresqlException).errorDetails
            if (errDetails.code == "23505") {
                val constraintName = errDetails.constraintName.get()
                if (constraintName == "unique_1") {
                    return InsertStatus.DUPLICATE_1
                } else if (constraintName == "unique_2") {
                    return InsertStatus.DUPLICATE_2
                }
            }
            return InsertStatus.UNKNOWN_ERROR
        }
    }

    private suspend fun doSave(xxx: XXX) {
        databaseClient
            .sql(
                """
                    SOME SQL
                """.trimIndent(),
            ).bind(...)
            .rowsUpdated()
            .awaitSingle()
    }

The problem that I face is during IntelliJ idea execution this code behaves as expected, so exception.cause is a subtype of PostgresqlException, but during gradle run with command ./gradlew clean build the exception.cause is wrapped around with another DuplicateKeyException, so essentialy the exception should be DuplicateKeyException(PostgresqlException) but effectively it is DuplicateKeyException(DuplicateKeyException(PostgresqlException)). And once again, this only happens during gradle run.

What could be the cause of this?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744702201a4588838.html

相关推荐

  • java - Gradle build unexpected behaviour vs IDE - Stack Overflow

    I have the following code which executes spring DatabaseClient insert logic:suspend fun saveXXX(xxx: XX

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信