Skip to content

Commit

Permalink
Merged in bugfix/SHIBUI-838 (pull request #248)
Browse files Browse the repository at this point in the history
[SHIBUI-838]
  • Loading branch information
Bill Smith authored and Jonathan Johnson committed Dec 4, 2018
2 parents 46526ab + c3e29b2 commit 4391e1c
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package edu.internet2.tier.shibboleth.admin.ui.controller.support;

import com.google.common.collect.ImmutableMap;
import edu.internet2.tier.shibboleth.admin.ui.controller.ErrorResponse;
import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.MetadataResolver;
import edu.internet2.tier.shibboleth.admin.ui.repository.MetadataResolverRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
Expand All @@ -30,12 +32,18 @@ public MetadataResolver findResolverOrThrowHttp404(String resolverResourceId) {
return resolver;
}


@ExceptionHandler
//TODO: Review this handler and update accordingly. Do we still need it?
@ExceptionHandler(HttpClientErrorException.class)
public ResponseEntity<?> notFoundHandler(HttpClientErrorException ex) {
if(ex.getStatusCode() == NOT_FOUND) {
return ResponseEntity.status(NOT_FOUND).body(ex.getStatusText());
}
throw ex;
}

@ExceptionHandler(Exception.class)
public final ResponseEntity<ErrorResponse> handleAllOtherExceptions(Exception ex) {
ErrorResponse errorResponse = new ErrorResponse("400", ex.getLocalizedMessage());
return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST);
}
}

0 comments on commit 4391e1c

Please sign in to comment.