Skip to content

Commit c3cd3db

Browse files
committed
fix: set missing descriptions for OAuth2Exceptions
This allows for propagation of these descriptions to the marshaled error responses by overriding the (rather generic) default descriptions.
1 parent 28605dc commit c3cd3db

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/kotlin/no/nav/security/mock/oauth2/OAuth2Exception.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ fun missingParameter(name: String): Nothing =
2323

2424
fun invalidGrant(grantType: GrantType): Nothing =
2525
"grant_type $grantType not supported.".let {
26-
throw OAuth2Exception(OAuth2Error.INVALID_GRANT, it)
26+
throw OAuth2Exception(OAuth2Error.INVALID_GRANT.setDescription(it), it)
2727
}
2828

2929
fun invalidRequest(message: String): Nothing =
3030
message.let {
31-
throw OAuth2Exception(OAuth2Error.INVALID_REQUEST, message)
31+
throw OAuth2Exception(OAuth2Error.INVALID_REQUEST.setDescription(message), message)
3232
}
3333

3434
fun notFound(message: String): Nothing = throw OAuth2Exception(ErrorObject("not_found", "Resource not found", HTTPResponse.SC_NOT_FOUND), message)

0 commit comments

Comments
 (0)