Skip to content

Commit

Permalink
Adds complete exception hierarchy and full error code / exception map…
Browse files Browse the repository at this point in the history
…ping from szerrors.json (#79)

* - Added missing exception classes to the class hierarchy
- Added full exception mapping according to szerrors.json from sz-sdk-errors

* Updated CHANGELOG.md for 0.9.1 release

* Resolved most linting issues

* Suppressed the MethodLength style check for the SzExceptionMapper.java file
  • Loading branch information
barrycaceres authored Jan 17, 2025
1 parent 71e1af8 commit add8804
Show file tree
Hide file tree
Showing 15 changed files with 1,673 additions and 481 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
[markdownlint](https://dlaa.me/markdownlint/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.9.1] - 2025-01-17

### Changed in 0.9.1

- Minor update for detection of the `CONFIGPATH` for auto tests
- Added full exception hierarchy:
- `SzConfigurationException`
- `SzRetryableException`
- `SzDatabaseConnectionLostException`
- `SzRetryTimeoutExceededException`
- `SzUnrecoverableException`
- `SzDatabaseException`
- `SzLicenseException`
- `SzNotInitializedException`
- `SzUnhandledException`
- Added full error code to exception mapping from `szerrors.json`

## [0.9.0] - 2024-12-18

- Initial release in preparation for beta testing of Senzing 4.0
1 change: 1 addition & 0 deletions checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
<suppress checks="HiddenField" files="."/>
<suppress checks="ParameterNumber" files="."/>
<suppress checks="MagicNumber" files="."/>
<suppress checks="MethodLength" files="src/main/java/com/senzing/sdk/core/SzExceptionMapper.java"/>
</suppressions>
72 changes: 72 additions & 0 deletions src/main/java/com/senzing/sdk/SzConfigurationException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.senzing.sdk;

/**
* Defines an exceptional condition when a failure has occurred
* pertaining to the Senzing configuration.
*/
public class SzConfigurationException extends SzException {
/**
* Default constructor.
*/
public SzConfigurationException() {
super();
}

/**
* Constructs with a message explaing the reason for the exception.
*
* @param message The message explaining the reason for the exception.
*/
public SzConfigurationException(String message) {
super(message);
}

/**
* Constructs with a message explaing the reason for the exception.
*
* @param errorCode The underlying senzing error code.
*
* @param message The message explaining the reason for the exception.
*/
public SzConfigurationException(int errorCode, String message) {
super(errorCode, message);
}

/**
* Constructs with the {@link Throwable} that is the underlying cause
* for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzConfigurationException(Throwable cause) {
super(cause);
}

/**
* Constructs with a message explaing the reason for the exception
* and the {@link Throwable} that is the underlying cause for the
* exception.
*
* @param message The message explaining the reason for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzConfigurationException(String message, Throwable cause) {
super(message, cause);
}

/**
* Constructs with the Senzing error code, the message explaing
* the reason for the exception and the {@link Throwable} that
* is the underlying cause for the exception.
*
* @param errorCode The underlying senzing error code.
*
* @param message The message explaining the reason for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzConfigurationException(int errorCode, String message, Throwable cause) {
super(errorCode, message, cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.senzing.sdk;

/**
* Extends {@link SzRetryableException} to define an exceptional condition
* where a database connection was lost causing a Senzing operation to fail.
* Retrying the operation would likely result in the connection being
* reestablished and the operation succeeding.
*/
public class SzDatabaseConnectionLostException extends SzRetryableException {
/**
* Default constructor.
*/
public SzDatabaseConnectionLostException() {
super();
}

/**
* Constructs with a message explaing the reason for the exception.
*
* @param message The message explaining the reason for the exception.
*/
public SzDatabaseConnectionLostException(String message) {
super(message);
}

/**
* Constructs with a message explaing the reason for the exception.
*
* @param errorCode The underlying senzing error code.
*
* @param message The message explaining the reason for the exception.
*/
public SzDatabaseConnectionLostException(int errorCode, String message) {
super(errorCode, message);
}

/**
* Constructs with the {@link Throwable} that is the underlying cause
* for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzDatabaseConnectionLostException(Throwable cause) {
super(cause);
}

/**
* Constructs with a message explaing the reason for the exception
* and the {@link Throwable} that is the underlying cause for the
* exception.
*
* @param message The message explaining the reason for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzDatabaseConnectionLostException(String message, Throwable cause) {
super(message, cause);
}

/**
* Constructs with the Senzing error code, the message explaing
* the reason for the exception and the {@link Throwable} that
* is the underlying cause for the exception.
*
* @param errorCode The underlying senzing error code.
*
* @param message The message explaining the reason for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzDatabaseConnectionLostException(int errorCode, String message, Throwable cause) {
super(errorCode, message, cause);
}
}
73 changes: 73 additions & 0 deletions src/main/java/com/senzing/sdk/SzDatabaseException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.senzing.sdk;

/**
* Extends {@link SzUnrecoverableException} to define an exceptional
* condition triggered by a database error from which we can recover
* (e.g.: missing or unexpected schema definition).
*/
public class SzDatabaseException extends SzUnrecoverableException {
/**
* Default constructor.
*/
public SzDatabaseException() {
super();
}

/**
* Constructs with a message explaing the reason for the exception.
*
* @param message The message explaining the reason for the exception.
*/
public SzDatabaseException(String message) {
super(message);
}

/**
* Constructs with a message explaing the reason for the exception.
*
* @param errorCode The underlying senzing error code.
*
* @param message The message explaining the reason for the exception.
*/
public SzDatabaseException(int errorCode, String message) {
super(errorCode, message);
}

/**
* Constructs with the {@link Throwable} that is the underlying cause
* for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzDatabaseException(Throwable cause) {
super(cause);
}

/**
* Constructs with a message explaing the reason for the exception
* and the {@link Throwable} that is the underlying cause for the
* exception.
*
* @param message The message explaining the reason for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzDatabaseException(String message, Throwable cause) {
super(message, cause);
}

/**
* Constructs with the Senzing error code, the message explaing
* the reason for the exception and the {@link Throwable} that
* is the underlying cause for the exception.
*
* @param errorCode The underlying senzing error code.
*
* @param message The message explaining the reason for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzDatabaseException(int errorCode, String message, Throwable cause) {
super(errorCode, message, cause);
}
}
73 changes: 73 additions & 0 deletions src/main/java/com/senzing/sdk/SzLicenseException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.senzing.sdk;

/**
* Extends {@link SzUnrecoverableException} to define an exceptional
* condition triggered by an invalid, expired or exhausted Senzing
* license.
*/
public class SzLicenseException extends SzUnrecoverableException {
/**
* Default constructor.
*/
public SzLicenseException() {
super();
}

/**
* Constructs with a message explaing the reason for the exception.
*
* @param message The message explaining the reason for the exception.
*/
public SzLicenseException(String message) {
super(message);
}

/**
* Constructs with a message explaing the reason for the exception.
*
* @param errorCode The underlying senzing error code.
*
* @param message The message explaining the reason for the exception.
*/
public SzLicenseException(int errorCode, String message) {
super(errorCode, message);
}

/**
* Constructs with the {@link Throwable} that is the underlying cause
* for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzLicenseException(Throwable cause) {
super(cause);
}

/**
* Constructs with a message explaing the reason for the exception
* and the {@link Throwable} that is the underlying cause for the
* exception.
*
* @param message The message explaining the reason for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzLicenseException(String message, Throwable cause) {
super(message, cause);
}

/**
* Constructs with the Senzing error code, the message explaing
* the reason for the exception and the {@link Throwable} that
* is the underlying cause for the exception.
*
* @param errorCode The underlying senzing error code.
*
* @param message The message explaining the reason for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzLicenseException(int errorCode, String message, Throwable cause) {
super(errorCode, message, cause);
}
}
72 changes: 72 additions & 0 deletions src/main/java/com/senzing/sdk/SzNotInitializedException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.senzing.sdk;

/**
* Extends {@link SzUnrecoverableException} to define an exceptional
* condition triggered by Senzing not being initialized.
*/
public class SzNotInitializedException extends SzUnrecoverableException {
/**
* Default constructor.
*/
public SzNotInitializedException() {
super();
}

/**
* Constructs with a message explaing the reason for the exception.
*
* @param message The message explaining the reason for the exception.
*/
public SzNotInitializedException(String message) {
super(message);
}

/**
* Constructs with a message explaing the reason for the exception.
*
* @param errorCode The underlying senzing error code.
*
* @param message The message explaining the reason for the exception.
*/
public SzNotInitializedException(int errorCode, String message) {
super(errorCode, message);
}

/**
* Constructs with the {@link Throwable} that is the underlying cause
* for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzNotInitializedException(Throwable cause) {
super(cause);
}

/**
* Constructs with a message explaing the reason for the exception
* and the {@link Throwable} that is the underlying cause for the
* exception.
*
* @param message The message explaining the reason for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzNotInitializedException(String message, Throwable cause) {
super(message, cause);
}

/**
* Constructs with the Senzing error code, the message explaing
* the reason for the exception and the {@link Throwable} that
* is the underlying cause for the exception.
*
* @param errorCode The underlying senzing error code.
*
* @param message The message explaining the reason for the exception.
*
* @param cause The message The message explaining the reason for the exception.
*/
public SzNotInitializedException(int errorCode, String message, Throwable cause) {
super(errorCode, message, cause);
}
}
Loading

0 comments on commit add8804

Please sign in to comment.