Skip to content

Commit de0cbdc

Browse files
authored
Merge pull request #556 from hmcts/DTSRD-261
DTSRD-261: Location endpoint throws 500 instead of 400 with missing param
2 parents 13f50e5 + 3347e42 commit de0cbdc

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/advice/ExceptionMapper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.springframework.http.ResponseEntity;
99
import org.springframework.http.converter.HttpMessageNotReadableException;
1010
import org.springframework.security.access.AccessDeniedException;
11+
import org.springframework.web.bind.MissingServletRequestParameterException;
1112
import org.springframework.web.bind.annotation.ControllerAdvice;
1213
import org.springframework.web.bind.annotation.ExceptionHandler;
1314
import org.springframework.web.bind.annotation.RequestMapping;
@@ -106,6 +107,11 @@ public ResponseEntity<Object> handleMethodArgumentTypeMismatchException(Exceptio
106107
return errorDetailsResponseEntity(ex, BAD_REQUEST, ex.getMessage());
107108
}
108109

110+
@ExceptionHandler(MissingServletRequestParameterException.class)
111+
public ResponseEntity<Object> handleMissingServletRequestParameterException(Exception ex) {
112+
return errorDetailsResponseEntity(ex, BAD_REQUEST, ex.getMessage());
113+
}
114+
109115
private String getTimeStamp() {
110116
return new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS", Locale.ENGLISH).format(new Date());
111117
}

0 commit comments

Comments
 (0)