X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=enrichment-coordinator-service%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fenrichment%2Fcontrollers%2FErrorResponse.java;h=c90a649173215c8900ee3283b02c3c29ee5b5f57;hb=a41966b2da6d7f74d4f486bc1492a5cbb5866583;hp=1df2df7396446a4364b465913587abc91bd483f3;hpb=6f86ab364ac739951556bf2d5bf70429b518de47;p=nonrtric.git diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java index 1df2df73..c90a6491 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java @@ -61,7 +61,7 @@ public class ErrorResponse { } @ApiModelProperty( - example = "503", + example = "404", value = "The HTTP status code generated by the origin server for this occurrence of the problem.") public Integer getStatus() { return status; @@ -73,7 +73,6 @@ public class ErrorResponse { public String getDetail() { return this.detail; } - } @ApiModelProperty(value = "message") @@ -83,24 +82,19 @@ public class ErrorResponse { this.message = message; } - public static Mono> createMono(String text, HttpStatus code) { - return Mono.just(create(text, code)); - } - public static Mono> createMono(Exception e, HttpStatus code) { - return createMono(e.toString(), code); + return Mono.just(create(e, code)); } - public static ResponseEntity create(String text, HttpStatus code) { - ErrorInfo p = new ErrorInfo(text, code.value()); + public static ResponseEntity create(Exception e, HttpStatus code) { + if (e instanceof RuntimeException) { + code = HttpStatus.INTERNAL_SERVER_ERROR; + } + ErrorInfo p = new ErrorInfo(e.toString(), code.value()); String json = gson.toJson(p); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_PROBLEM_JSON); return new ResponseEntity<>(json, headers, code); } - public static ResponseEntity create(Exception e, HttpStatus code) { - return create(e.toString(), code); - } - }