Skip to content

Commit

Permalink
Throw Runtime exceptions. (#137)
Browse files Browse the repository at this point in the history
The exception classes generated by Fabrikt for the client are not triggering Spring's [@transactional](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/transaction/annotation/Transactional.html) to rollback transactions.

This is because the Fabrikt generated exceptions extend Exception instead of RuntimeException.

> In its default configuration, the Spring Framework’s transaction infrastructure code only marks a transaction for rollback in the case of runtime, unchecked exceptions; that is, when the thrown exception is an instance or subclass of RuntimeException.
  • Loading branch information
cjbooms authored Jul 19, 2022
1 parent c0b5fac commit f16f855
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/templates/client-code/api-models.kt.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class ApiResponse<T>(val statusCode: Int, val headers: Headers, val data: T
/**
* API non-2xx failure responses returned by API call.
*/
open class ApiException(override val message: String) : Exception(message)
open class ApiException(override val message: String) : RuntimeException(message)

/**
* API 4xx failure responses returned by API call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class ApiResponse<T>(val statusCode: Int, val headers: Headers, val data: T
/**
* API non-2xx failure responses returned by API call.
*/
open class ApiException(override val message: String) : Exception(message)
open class ApiException(override val message: String) : RuntimeException(message)

/**
* API 4xx failure responses returned by API call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class ApiResponse<T>(val statusCode: Int, val headers: Headers, val data: T
/**
* API non-2xx failure responses returned by API call.
*/
open class ApiException(override val message: String) : Exception(message)
open class ApiException(override val message: String) : RuntimeException(message)

/**
* API 4xx failure responses returned by API call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class ApiResponse<T>(val statusCode: Int, val headers: Headers, val data: T
/**
* API non-2xx failure responses returned by API call.
*/
open class ApiException(override val message: String) : Exception(message)
open class ApiException(override val message: String) : RuntimeException(message)

/**
* API 4xx failure responses returned by API call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class ApiResponse<T>(val statusCode: Int, val headers: Headers, val data: T
/**
* API non-2xx failure responses returned by API call.
*/
open class ApiException(override val message: String) : Exception(message)
open class ApiException(override val message: String) : RuntimeException(message)

/**
* API 4xx failure responses returned by API call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class ApiResponse<T>(val statusCode: Int, val headers: Headers, val data: T
/**
* API non-2xx failure responses returned by API call.
*/
open class ApiException(override val message: String) : Exception(message)
open class ApiException(override val message: String) : RuntimeException(message)

/**
* API 4xx failure responses returned by API call.
Expand Down

0 comments on commit f16f855

Please sign in to comment.