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=20e9f76265e9b56b4578dbeb39421f29cab105b6;hb=af40dc43f26d3fea66ac04625080314162e93496;hp=1df2df7396446a4364b465913587abc91bd483f3;hpb=d1d085456c485599f6b8aba87b6d761b29c2ecd4;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..20e9f762 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,23 @@ 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 Mono.just(create(e, code)); } - public static Mono> createMono(Exception e, HttpStatus code) { - return createMono(e.toString(), code); + public static ResponseEntity create(Exception e, HttpStatus code) { + if (e instanceof RuntimeException) { + code = HttpStatus.INTERNAL_SERVER_ERROR; + } + return create(e.toString(), code); } - public static ResponseEntity create(String text, HttpStatus code) { - ErrorInfo p = new ErrorInfo(text, code.value()); - String json = gson.toJson(p); + public static ResponseEntity create(String str, HttpStatus code) { + ErrorInfo errorInfo = new ErrorInfo(str, code.value()); + String json = gson.toJson(errorInfo); 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); - } - }