Skip to content

Commit

Permalink
style: fix import, white-space and sonar lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGreatRefrigerator committed Jul 7, 2023
1 parent 0a5626e commit 46c9d85
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand All @@ -48,7 +47,7 @@

import javax.servlet.http.HttpServletResponse;

@RestController
@RestController
@Tag(name = "Directions Service", description = "Get directions for different modes of transport")
@RequestMapping("/v2/directions")
@ApiResponse(responseCode = "400", description = "The request is incorrect and therefore can not be processed.")
Expand Down Expand Up @@ -214,16 +213,16 @@ public ResponseEntity<Object> handleMissingParams(final MissingServletRequestPar
@ExceptionHandler({HttpMessageNotReadableException.class, ConversionFailedException.class, HttpMessageConversionException.class, Exception.class})
public ResponseEntity<Object> handleReadingBodyException(final Exception e) {
final Throwable cause = e.getCause();
if (cause instanceof UnrecognizedPropertyException) {
return errorHandler.handleUnknownParameterException(new UnknownParameterException(RoutingErrorCodes.UNKNOWN_PARAMETER, ((UnrecognizedPropertyException) cause).getPropertyName()));
} else if (cause instanceof InvalidFormatException) {
return errorHandler.handleStatusCodeException(new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_FORMAT, "" + ((InvalidFormatException) cause).getValue()));
} else if (cause instanceof ConversionFailedException) {
return errorHandler.handleStatusCodeException(new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, "" + ((ConversionFailedException) cause).getValue()));
} else if (cause instanceof InvalidDefinitionException) {
return errorHandler.handleStatusCodeException(new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, ((InvalidDefinitionException) cause).getPath().get(0).getFieldName()));
} else if (cause instanceof MismatchedInputException) {
return errorHandler.handleStatusCodeException(new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_FORMAT, ((MismatchedInputException) cause).getPath().get(0).getFieldName()));
if (cause instanceof UnrecognizedPropertyException exception) {
return errorHandler.handleUnknownParameterException(new UnknownParameterException(RoutingErrorCodes.UNKNOWN_PARAMETER, exception.getPropertyName()));
} else if (cause instanceof InvalidFormatException exception) {
return errorHandler.handleStatusCodeException(new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_FORMAT, "" + exception.getValue()));
} else if (cause instanceof ConversionFailedException exception) {
return errorHandler.handleStatusCodeException(new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, "" + exception.getValue()));
} else if (cause instanceof InvalidDefinitionException exception) {
return errorHandler.handleStatusCodeException(new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_VALUE, exception.getPath().get(0).getFieldName()));
} else if (cause instanceof MismatchedInputException exception) {
return errorHandler.handleStatusCodeException(new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_FORMAT, exception.getPath().get(0).getFieldName()));
} else {
// Check if we are missing the body as a whole
if (e.getLocalizedMessage().startsWith("Required request body is missing")) {
Expand Down

0 comments on commit 46c9d85

Please sign in to comment.