File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/main/kotlin/com/ashampoo/imageproxy Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import kotlinx.coroutines.CompletableDeferred
3131import kotlinx.coroutines.Dispatchers
3232import kotlinx.coroutines.withContext
3333import java.io.ByteArrayOutputStream
34+ import java.net.ConnectException
3435import kotlin.math.max
3536import kotlin.math.round
3637
@@ -84,11 +85,18 @@ fun Application.configureRouting() {
8485 return @get
8586 }
8687
87- val response = httpClient.get(remoteUrl) {
88+ val response = try {
8889
89- /* If set, pass the auth token on to the remote service */
90- if (authToken != null )
91- header(AUTHORIZATION_HEADER , authToken)
90+ httpClient.get(remoteUrl) {
91+
92+ /* If set, pass the auth token on to the remote service */
93+ if (authToken != null )
94+ header(AUTHORIZATION_HEADER , authToken)
95+ }
96+
97+ } catch (ex: ConnectException ) {
98+ call.respond(HttpStatusCode .InternalServerError , " Failed to connect to $remoteUrl " )
99+ return @get
92100 }
93101
94102 /* If the remote URL requires authorization we forward it as is. */
You can’t perform that action at this time.
0 commit comments