-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dependency on runtime-micronaut project entirely from codegen (#…
…14) * Add exception classes and handlers in runtime module * Remove codegen logic for generating excepiton classes, move HttpStatusToExceptionClassMapper to runtime module * Fix import in test * Set dependency of codegen on runtime-micronaut to 'compileOnly' * remove runtime dependency on codegen as it would result in getting all micronaut dependencies in codegen. Using string paths of exception files * Move basePackage name of exception classes inside mapper
- Loading branch information
1 parent
b76da80
commit 1c0cf9d
Showing
5 changed files
with
32 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
codegen/src/main/kotlin/apifi/helpers/HttpStatusToExceptionClassMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package apifi.helpers | ||
|
||
|
||
class HttpStatusToExceptionClassMapper { | ||
|
||
val basePackageName = "apifi.micronaut.exceptions" | ||
|
||
private val allExceptionDetailsHolder = listOf( | ||
ExceptionDetailsHolder(400, "BadRequestException"), | ||
ExceptionDetailsHolder(401, "UnauthorizedException"), | ||
ExceptionDetailsHolder(403, "ForbiddenException"), | ||
ExceptionDetailsHolder(404, "NotFoundException"), | ||
ExceptionDetailsHolder(500, "InternalServerErrorException") | ||
) | ||
|
||
class ExceptionDetailsHolder( | ||
val status: Int, | ||
val exceptionClassPath: String | ||
) | ||
|
||
fun getExceptionClassFor(statuses: List<Int>) = statuses.map { status -> allExceptionDetailsHolder.find { it.status == status }?.exceptionClassPath ?: "InternalServerErrorException" } | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
...-micronaut/src/main/kotlin/apifi/micronaut/exceptions/HttpStatusToExceptionClassMapper.kt
This file was deleted.
Oops, something went wrong.