Skip to content

Commit

Permalink
secureCodeBox#121 Introduce Our Own Exception Type Hierarchy
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Strittmatter <[email protected]>
  • Loading branch information
Weltraumschaf committed Mar 5, 2024
1 parent 1819cb7 commit 59bbda4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
package io.securecodebox.persistence.defectdojo.exception;

/**
* Indicates a missing {@link io.securecodebox.persistence.defectdojo.config.Config config property}
* Indicates a missing/bad {@link io.securecodebox.persistence.defectdojo.config.Config config property}
*/
public final class ConfigException extends RuntimeException {
public final class ConfigException extends PersistenceException {
public ConfigException(final String message) {
super(message);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

package io.securecodebox.persistence.defectdojo.exception;

public final class PersistenceException extends RuntimeException {
/**
* Generic exception which is thrown for any unforeseen error at runtime
*/
public class PersistenceException extends RuntimeException {
public PersistenceException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-FileCopyrightText: the secureCodeBox authors
//
// SPDX-License-Identifier: Apache-2.0

package io.securecodebox.persistence.defectdojo.exception;

import io.securecodebox.persistence.defectdojo.config.Config;

/**
* Thrown if we receive more objects than {@link Config#getMaxPageCountForGets() configured}
*/
public final class TooManyResponsesException extends PersistenceException {
public TooManyResponsesException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.fasterxml.jackson.databind.cfg.CoercionAction;
import com.fasterxml.jackson.databind.cfg.CoercionInputShape;
import io.securecodebox.persistence.defectdojo.config.Config;
import io.securecodebox.persistence.defectdojo.exception.LoopException;
import io.securecodebox.persistence.defectdojo.exception.TooManyResponsesException;
import io.securecodebox.persistence.defectdojo.http.Foo;
import io.securecodebox.persistence.defectdojo.http.ProxyConfigFactory;
import io.securecodebox.persistence.defectdojo.model.Engagement;
Expand Down Expand Up @@ -142,7 +142,7 @@ public List<T> search(Map<String, Object> queryParams) throws URISyntaxException

hasNext = response.getNext() != null;
if (page > this.config.getMaxPageCountForGets()) {
throw new LoopException("Found too many response object. Quitting after " + (page - 1) + " paginated API pages of " + DEFECT_DOJO_OBJET_LIMIT + " each.");
throw new TooManyResponsesException("Found too many response object. Quitting after " + (page - 1) + " paginated API pages of " + DEFECT_DOJO_OBJET_LIMIT + " each.");
}
} while (hasNext);

Expand Down

0 comments on commit 59bbda4

Please sign in to comment.