-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 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
15 changes: 15 additions & 0 deletions
15
...-binance/src/main/kotlin/com/njkim/reactivecrypto/binance/http/raw/binanceErrorHandler.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,15 @@ | ||
package com.njkim.reactivecrypto.binance.http.raw | ||
|
||
import com.njkim.reactivecrypto.binance.model.BinanceApiException | ||
import com.njkim.reactivecrypto.binance.model.BinanceErrorResponse | ||
import org.springframework.web.reactive.function.client.WebClient | ||
|
||
/** | ||
Created by jay on 2019-07-04 | ||
**/ | ||
fun WebClient.ResponseSpec.binanceErrorHandling(): WebClient.ResponseSpec = onStatus( | ||
{ it.isError }, | ||
{ clientResponse -> | ||
clientResponse.bodyToMono(BinanceErrorResponse::class.java) | ||
.map { BinanceApiException(clientResponse.statusCode(), it) } | ||
}) |
24 changes: 24 additions & 0 deletions
24
...pto-binance/src/main/kotlin/com/njkim/reactivecrypto/binance/model/BinanceApiException.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,24 @@ | ||
/* | ||
* Copyright 2019 namjug-kim | ||
* | ||
* LINE Corporation licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.njkim.reactivecrypto.binance.model | ||
|
||
import org.springframework.http.HttpStatus | ||
|
||
data class BinanceApiException( | ||
val httpStatus: HttpStatus, | ||
val binanceErrorResponse: BinanceErrorResponse | ||
) : RuntimeException() |
19 changes: 19 additions & 0 deletions
19
...to-binance/src/main/kotlin/com/njkim/reactivecrypto/binance/model/BinanceErrorResponse.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,19 @@ | ||
/* | ||
* Copyright 2019 namjug-kim | ||
* | ||
* LINE Corporation licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.njkim.reactivecrypto.binance.model | ||
|
||
data class BinanceErrorResponse(val code: Int, val msg: String) |