Skip to content

Commit

Permalink
Error streamlining
Browse files Browse the repository at this point in the history
  • Loading branch information
codepitbull committed Dec 11, 2024
1 parent 96e533c commit 4d2aea1
Show file tree
Hide file tree
Showing 49 changed files with 358 additions and 426 deletions.
327 changes: 165 additions & 162 deletions ext/hivemq-edge-openapi-2024.8-SNAPSHOT.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CustomJsonMappingExceptionMapper implements ExceptionMapper<JsonMap
public @NotNull Response toResponse(final @NotNull JsonMappingException exception) {
final String originalMessage = exception.getOriginalMessage();
if (originalMessage != null) {
return ErrorResponseUtil.errorResponse(new ValidationError(List.of(new Error(originalMessage, null, null, null))));
return ErrorResponseUtil.errorResponse(new ValidationError(List.of(new Error(originalMessage, null))));
} else {
return ErrorResponseUtil.errorResponse(new InvalidInputError("Unable to parse JSON body, please check the input format."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class CustomJsonParseExceptionMapper implements ExceptionMapper<JsonParse
public @NotNull Response toResponse(final JsonParseException exception) {
final String originalMessage = exception.getOriginalMessage();
if (originalMessage != null) {
return ErrorResponseUtil.errorResponse(new ValidationError(List.of(new Error(originalMessage, null, null, null))));
return ErrorResponseUtil.errorResponse(new ValidationError(List.of(new Error(originalMessage, null))));
} else {
return ErrorResponseUtil.errorResponse(new InvalidInputError("Unable to parse JSON body, please check the input format."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class AlreadyExistsError extends Errors {
public class AlreadyExistsError extends ProblemDetails {
public AlreadyExistsError(
final @Nullable String error) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class BadRequestError extends Errors {
public class BadRequestError extends ProblemDetails {
public BadRequestError(
final @Nullable String error) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class BodyParameterMissingError extends Errors {
public class BodyParameterMissingError extends ProblemDetails {
public BodyParameterMissingError(String parameterName) {
super(
"BodyParameterMissing",
"Required request body parameter missing",
"Required request body parameter missing",
HttpStatus.BAD_REQUEST_400,
List.of(new Error("Request body parameter missing: " + parameterName, parameterName, null, null)));
List.of(new Error("Request body parameter missing: " + parameterName, parameterName)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class InsufficientStorageError extends Errors {
public class InsufficientStorageError extends ProblemDetails {
public InsufficientStorageError(
final @NotNull String cause) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class InternalServerError extends Errors {
public class InternalServerError extends ProblemDetails {
public InternalServerError(
final @Nullable String error) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class InvalidInputError extends Errors {
public class InvalidInputError extends ProblemDetails {
public InvalidInputError(
final @Nullable String error) {
super(
"InvalidInputError",
"Invalid input",
"JSON failed validation.",
HttpStatus.BAD_REQUEST_400,
List.of(new Error("Unparseable JSON: " + error, null, null, null)));
List.of(new Error("Unparseable JSON: " + error, null)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class InvalidQueryParameterError extends Errors {
public class InvalidQueryParameterError extends ProblemDetails {
public InvalidQueryParameterError(String parameterName, String reason) {
super(
"InvalidQueryParameter",
"Query parameter is invalid",
"Query parameter is invalid",
HttpStatus.BAD_REQUEST_400,
List.of(new Error(String.format("Query parameter %s is invalid: %s", parameterName, reason), parameterName, null, null)));
List.of(new Error(String.format("Query parameter %s is invalid: %s", parameterName, reason), parameterName)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class InvalidQueryParameterErrors extends Errors {
public class InvalidQueryParameterErrors extends ProblemDetails {
public InvalidQueryParameterErrors(List<Error> errors) {
super(
"InvalidQueryParameter",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.hivemq.api.errors;

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class MethodNotAllowedError extends Errors {
public class MethodNotAllowedError extends ProblemDetails {
public MethodNotAllowedError() {
super(
"MethodNotAllowedError",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.hivemq.api.errors;

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import org.jetbrains.annotations.Nullable;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class NotFoundError extends Errors {
public class NotFoundError extends ProblemDetails {
public NotFoundError() {
super(
"NotFoundError",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class PreconditionFailedError extends Errors {
public class PreconditionFailedError extends ProblemDetails {
public PreconditionFailedError(
final @NotNull String cause) {
super(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.hivemq.api.errors;

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Errors;
import org.jetbrains.annotations.Nullable;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class TemporaryNotAvailableError extends Errors {
public class TemporaryNotAvailableError extends ProblemDetails {
public TemporaryNotAvailableError() {
super(
"TemporaryUnavailable",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.hivemq.api.errors;

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class UnsupportedMediaTypeError extends Errors {
public class UnsupportedMediaTypeError extends ProblemDetails {
public UnsupportedMediaTypeError() {
super(
"UnsupportedMediaTypeError",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class UrlParameterMissingError extends Errors {
public class UrlParameterMissingError extends ProblemDetails {
public UrlParameterMissingError(String parameterName) {
super(
"UrlParameterMissing",
"Required url parameter missing",
"Required url parameter missing",
HttpStatus.BAD_REQUEST_400,
List.of(new Error("URL parameter missing: " + parameterName, parameterName, null, null)));
List.of(new Error("URL parameter missing: " + parameterName, parameterName)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class ValidationError extends Errors {
public class ValidationError extends ProblemDetails {
public ValidationError(
final @Nullable List<Error> errors) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class AdapterFailedSchemaValidationError extends Errors {
public class AdapterFailedSchemaValidationError extends ProblemDetails {
public AdapterFailedSchemaValidationError(List<Error> errors) {
super(
"AdapterFailedValidation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class AdapterFailedValidationError extends Errors {
public class AdapterFailedValidationError extends ProblemDetails {
public AdapterFailedValidationError(String error) {
super(
"AdapterFailedValidation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class AdapterNotFound403Error extends Errors {
public class AdapterNotFound403Error extends ProblemDetails {
public AdapterNotFound403Error(String error) {
super(
"AdapterNotFound",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class AdapterNotFoundError extends Errors {
public class AdapterNotFoundError extends ProblemDetails {
public AdapterNotFoundError(String error) {
super(
"AdapterNotFound",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class AdapterOperationNotSupportedError extends Errors {
public class AdapterOperationNotSupportedError extends ProblemDetails {
public AdapterOperationNotSupportedError(String error) {
super(
"AdapterTypeOperationNotSupported",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class AdapterTypeNotFoundError extends Errors {
public class AdapterTypeNotFoundError extends ProblemDetails {
public AdapterTypeNotFoundError(String error) {
super(
"AdapterTypeNotFound",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class AdapterTypeReadOnlyError extends Errors {
public class AdapterTypeReadOnlyError extends ProblemDetails {
public AdapterTypeReadOnlyError(String error) {
super(
"AdapterTypeReadOnly",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class DomainTagNotFoundError extends Errors {
public class DomainTagNotFoundError extends ProblemDetails {
public DomainTagNotFoundError(String error) {
super(
"TagNotFound",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.hivemq.http.HttpStatus;
import com.hivemq.http.error.Error;
import com.hivemq.http.error.Errors;
import com.hivemq.http.error.ProblemDetails;

import java.util.List;

public class AuthenticationValidationError extends Errors {
public class AuthenticationValidationError extends ProblemDetails {
public AuthenticationValidationError(List<Error> errors) {
super(
"AuthenticationValidationError",
Expand Down
Loading

0 comments on commit 4d2aea1

Please sign in to comment.