-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify SynqOrderService and SynqProductService
- Loading branch information
1 parent
070fcaa
commit f5c8a5e
Showing
3 changed files
with
41 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,27 @@ | ||
package no.nb.mlt.wls.core.data.synq | ||
|
||
data class SynqError(val errorCode: Int, val errorText: String) | ||
import org.springframework.web.reactive.function.client.WebClientResponseException | ||
import org.springframework.web.server.ServerErrorException | ||
|
||
data class SynqError(val errorCode: Int, val errorText: String) { | ||
companion object { | ||
/** | ||
* Converts a WebClient error into a ServerErrorException. | ||
* This is used for propagating error data to the client. | ||
* @see ServerErrorException | ||
* @see no.nb.mlt.wls.order.service.SynqOrderService | ||
* @see no.nb.mlt.wls.product.service.SynqProductService | ||
*/ | ||
fun createServerError(error: WebClientResponseException): ServerErrorException { | ||
val errorBody = error.getResponseBodyAs(SynqError::class.java) | ||
|
||
return ServerErrorException( | ||
"Failed to create product in SynQ, the storage system responded with error code: " + | ||
"'${errorBody?.errorCode ?: "NO ERROR CODE FOUND"}' " + | ||
"and error text: " + | ||
"'${errorBody?.errorText ?: "NO ERROR TEXT FOUND"}'", | ||
error | ||
) | ||
} | ||
} | ||
} |
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