org.zalando.problem.Status Java Examples

The following examples show how to use org.zalando.problem.Status. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExceptionTranslator.java    From cubeai with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler(ConcurrencyFailureException.class)
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.CONFLICT)
        .with("message", ErrorConstants.ERR_CONCURRENCY_FAILURE)
        .build();
    return create(ex, problem, request);
}
 
Example #2
Source File: ProblemUtil.java    From loc-framework with MIT License 5 votes vote down vote up
static Problem createProblem(String detail, int code, Status status) {
  String traceId = MDC.get("traceId");
  if (traceId != null) {
    return Problem.builder().withDetail(detail).with("code", code).with("traceId", traceId)
        .withStatus(status).build();
  } else {
    return Problem.builder().withDetail(detail).with("code", code).withStatus(status).build();
  }
}
 
Example #3
Source File: ExceptionTranslator.java    From e-commerce-microservice with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.CONFLICT)
        .with("message", ErrorConstants.ERR_CONCURRENCY_FAILURE)
        .build();
    return create(ex, problem, request);
}
 
Example #4
Source File: ExceptionTranslator.java    From alchemy with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.CONFLICT)
        .with(MESSAGE_KEY, ErrorConstants.ERR_CONCURRENCY_FAILURE)
        .build();
    return create(ex, problem, request);
}
 
Example #5
Source File: FeignClientSampleFallBackFactory.java    From loc-framework with MIT License 5 votes vote down vote up
@Override
public FeignClientSample create(Throwable throwable) {
  return () -> {
    log.error("错误:{}", throwable.getMessage(), throwable);
    return Problem.valueOf(Status.BAD_REQUEST);
  };
}
 
Example #6
Source File: ExceptionTranslator.java    From e-commerce-microservice with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.CONFLICT)
        .with("message", ErrorConstants.ERR_CONCURRENCY_FAILURE)
        .build();
    return create(ex, problem, request);
}
 
Example #7
Source File: ExceptionTranslator.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleNoSuchElementException(NoSuchElementException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.NOT_FOUND)
        .with(MESSAGE_KEY, ErrorConstants.ENTITY_NOT_FOUND_TYPE)
        .build();
    return create(ex, problem, request);
}
 
Example #8
Source File: ExceptionTranslator.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.CONFLICT)
        .with(MESSAGE_KEY, ErrorConstants.ERR_CONCURRENCY_FAILURE)
        .build();
    return create(ex, problem, request);
}
 
Example #9
Source File: ExceptionTranslator.java    From ehcache3-samples with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleNoSuchElementException(NoSuchElementException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.NOT_FOUND)
        .with("message", ErrorConstants.ENTITY_NOT_FOUND_TYPE)
        .build();
    return create(ex, problem, request);
}
 
Example #10
Source File: ExceptionTranslator.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.CONFLICT)
        .with(MESSAGE_KEY, ErrorConstants.ERR_CONCURRENCY_FAILURE)
        .build();
    return create(ex, problem, request);
}
 
Example #11
Source File: ExceptionTranslator.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleNoSuchElementException(NoSuchElementException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.NOT_FOUND)
        .with(MESSAGE_KEY, ErrorConstants.ENTITY_NOT_FOUND_TYPE)
        .build();
    return create(ex, problem, request);
}
 
Example #12
Source File: ExceptionTranslator.java    From TeamDojo with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.CONFLICT)
        .with(MESSAGE_KEY, ErrorConstants.ERR_CONCURRENCY_FAILURE)
        .build();
    return create(ex, problem, request);
}
 
Example #13
Source File: ExceptionTranslator.java    From TeamDojo with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleNoSuchElementException(NoSuchElementException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.NOT_FOUND)
        .with(MESSAGE_KEY, ErrorConstants.ENTITY_NOT_FOUND_TYPE)
        .build();
    return create(ex, problem, request);
}
 
Example #14
Source File: ExceptionTranslator.java    From Full-Stack-Development-with-JHipster with MIT License 5 votes vote down vote up
@ExceptionHandler(ConcurrencyFailureException.class)
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.CONFLICT)
        .with("message", ErrorConstants.ERR_CONCURRENCY_FAILURE)
        .build();
    return create(ex, problem, request);
}
 
Example #15
Source File: ExceptionTranslator.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleNoSuchElementException(NoSuchElementException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.NOT_FOUND)
        .with("message", ErrorConstants.ENTITY_NOT_FOUND_TYPE)
        .build();
    return create(ex, problem, request);
}
 
Example #16
Source File: ExceptionTranslator.java    From Full-Stack-Development-with-JHipster with MIT License 5 votes vote down vote up
@ExceptionHandler(NoSuchElementException.class)
public ResponseEntity<Problem> handleNoSuchElementException(NoSuchElementException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.NOT_FOUND)
        .with("message", ErrorConstants.ENTITY_NOT_FOUND_TYPE)
        .build();
    return create(ex, problem, request);
}
 
Example #17
Source File: ExceptionTranslator.java    From e-commerce-microservice with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleNoSuchElementException(NoSuchElementException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.NOT_FOUND)
        .with("message", ErrorConstants.ENTITY_NOT_FOUND_TYPE)
        .build();
    return create(ex, problem, request);
}
 
Example #18
Source File: ExceptionTranslator.java    From cubeai with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler(ConcurrencyFailureException.class)
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.CONFLICT)
        .with("message", ErrorConstants.ERR_CONCURRENCY_FAILURE)
        .build();
    return create(ex, problem, request);
}
 
Example #19
Source File: ExceptionTranslator.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleNoSuchElementException(NoSuchElementException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.NOT_FOUND)
        .with("message", ErrorConstants.ENTITY_NOT_FOUND_TYPE)
        .build();
    return create(ex, problem, request);
}
 
Example #20
Source File: ExceptionTranslator.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.CONFLICT)
        .with("message", ErrorConstants.ERR_CONCURRENCY_FAILURE)
        .build();
    return create(ex, problem, request);
}
 
Example #21
Source File: ExceptionTranslator.java    From e-commerce-microservice with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleNoSuchElementException(NoSuchElementException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.NOT_FOUND)
        .with("message", ErrorConstants.ENTITY_NOT_FOUND_TYPE)
        .build();
    return create(ex, problem, request);
}
 
Example #22
Source File: LocServiceAdviceTrait.java    From loc-framework with MIT License 5 votes vote down vote up
@API(status = API.Status.INTERNAL)
@ExceptionHandler(value = ConstraintViolationException.class)
default ResponseEntity<Problem> handleConstraintViolationException(
    final ConstraintViolationException constraintViolationException,
    final NativeWebRequest request) {
  return this.create(constraintViolationException, ProblemUtil.createProblem(
      constraintViolationException.getConstraintViolations().stream()
          .map(ConstraintViolation::getMessage).collect(Collectors.joining(",")),
      CONSTRAINT_VIOLATION_ERROR_CODE), request);
}
 
Example #23
Source File: ExceptionTranslator.java    From ehcache3-samples with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.CONFLICT)
        .with("message", ErrorConstants.ERR_CONCURRENCY_FAILURE)
        .build();
    return create(ex, problem, request);
}
 
Example #24
Source File: LocServiceAdviceTrait.java    From loc-framework with MIT License 5 votes vote down vote up
@API(status = API.Status.INTERNAL)
@ExceptionHandler(value = MethodArgumentNotValidException.class)
default ResponseEntity<Problem> handleMethodArgumentNotValidException(
    final MethodArgumentNotValidException methodArgumentNotValidException,
    final NativeWebRequest request) {
  List<FieldError> fieldErrors = methodArgumentNotValidException.getBindingResult().getFieldErrors();
  return this.create(methodArgumentNotValidException, ProblemUtil.createProblem(
      fieldErrors.stream().map(e -> e.getField() + ":" + e.getDefaultMessage())
          .collect(Collectors.joining(",")), METHOD_ARGUMENT_NOT_VALID_ERROR_CODE), request);
}
 
Example #25
Source File: ExceptionTranslator.java    From e-commerce-microservice with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
public ResponseEntity<Problem> handleNoSuchElementException(NoSuchElementException ex, NativeWebRequest request) {
    Problem problem = Problem.builder()
        .withStatus(Status.NOT_FOUND)
        .with("message", ErrorConstants.ENTITY_NOT_FOUND_TYPE)
        .build();
    return create(ex, problem, request);
}
 
Example #26
Source File: ProblemUtil.java    From loc-framework with MIT License 5 votes vote down vote up
static Problem createProblem(String detail, int code, Object data) {
  String traceId = MDC.get("traceId");
  if (traceId != null) {
    return Problem.builder().withDetail(detail).with("code", code).with("data", data)
        .with("traceId", traceId).withStatus(Status.OK).build();
  } else {
    return Problem.builder().withDetail(detail).with("code", code).with("data", data)
        .withStatus(Status.OK).build();
  }
}
 
Example #27
Source File: EmailNotFoundException.java    From cubeai with Apache License 2.0 4 votes vote down vote up
public EmailNotFoundException() {
    super(ErrorConstants.EMAIL_NOT_FOUND_TYPE, "Email address not registered", Status.BAD_REQUEST);
}
 
Example #28
Source File: InternalServerErrorException.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 4 votes vote down vote up
public InternalServerErrorException(String message) {
    super(ErrorConstants.DEFAULT_TYPE, message, Status.INTERNAL_SERVER_ERROR);
}
 
Example #29
Source File: InvalidPasswordException.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
public InvalidPasswordException() {
    super(ErrorConstants.INVALID_PASSWORD_TYPE, "Incorrect password", Status.BAD_REQUEST);
}
 
Example #30
Source File: EmailNotFoundException.java    From Spring-5.0-Projects with MIT License 4 votes vote down vote up
public EmailNotFoundException() {
    super(ErrorConstants.EMAIL_NOT_FOUND_TYPE, "Email address not registered", Status.BAD_REQUEST);
}