3838import org .springframework .util .CollectionUtils ;
3939import org .springframework .util .LinkedMultiValueMap ;
4040import org .springframework .util .MultiValueMap ;
41+ import org .springframework .util .StreamUtils ;
4142import org .springframework .util .unit .DataSize ;
4243import org .springframework .web .client .RestClient ;
4344
@@ -175,7 +176,12 @@ public void awaitFinalStatus() {
175176 }
176177 catch (DeploymentNotFoundException ex ) {
177178 // Sometimes Sonatype returns 404 for newly created deployments
178- this .logger .debug ("Got 404 while checking status" );
179+ this .logger .debug (ex .getMessage ());
180+ sleep ();
181+ continue ;
182+ }
183+ catch (InternalServerErrorException ex ) {
184+ this .logger .log (ex .getMessage ());
179185 sleep ();
180186 continue ;
181187 }
@@ -216,8 +222,13 @@ private DeploymentStatusDto fetchDeploymentStatus() {
216222 return this .restClient .post ()
217223 .uri ("/api/v1/publisher/status?id={deploymentId}" , this .deploymentId )
218224 .retrieve ()
219- .onStatus (this ::is404 , (res , req ) -> {
220- throw new DeploymentNotFoundException ();
225+ .onStatus (this ::is404 , (req , res ) -> {
226+ throw new DeploymentNotFoundException (res .getStatusCode (), res .getStatusText (),
227+ StreamUtils .copyToString (res .getBody (), StandardCharsets .UTF_8 ));
228+ })
229+ .onStatus (HttpStatusCode ::is5xxServerError , (req , res ) -> {
230+ throw new InternalServerErrorException (res .getStatusCode (), res .getStatusText (),
231+ StreamUtils .copyToString (res .getBody (), StandardCharsets .UTF_8 ));
221232 })
222233 .body (DeploymentStatusDto .class );
223234 }
@@ -243,6 +254,21 @@ private static final class DeploymentNotFoundException extends RuntimeException
243254 @ Serial
244255 private static final long serialVersionUID = 1L ;
245256
257+ DeploymentNotFoundException (HttpStatusCode statusCode , String statusText , String body ) {
258+ super ("Got %d '%s' while checking status. Body:\n %s" .formatted (statusCode .value (), statusText , body ));
259+ }
260+
261+ }
262+
263+ private static final class InternalServerErrorException extends RuntimeException {
264+
265+ @ Serial
266+ private static final long serialVersionUID = 1L ;
267+
268+ InternalServerErrorException (HttpStatusCode statusCode , String statusText , String body ) {
269+ super ("Got %d '%s' while checking status. Body:\n %s" .formatted (statusCode .value (), statusText , body ));
270+ }
271+
246272 }
247273
248274 }
0 commit comments