Skip to content

feat(licensedb): Add exception handling classes for error management#3894

Open
ADITYA-CODE-SOURCE wants to merge 1 commit intoeclipse-sw360:mainfrom
ADITYA-CODE-SOURCE:licensedb/exception-classes
Open

feat(licensedb): Add exception handling classes for error management#3894
ADITYA-CODE-SOURCE wants to merge 1 commit intoeclipse-sw360:mainfrom
ADITYA-CODE-SOURCE:licensedb/exception-classes

Conversation

@ADITYA-CODE-SOURCE
Copy link
Contributor

@ADITYA-CODE-SOURCE ADITYA-CODE-SOURCE commented Mar 13, 2026

Summary

Add custom exception classes for LicenseDB integration to handle various error scenarios when communicating with the external LicenseDB service.

Changes

Added 4 new exception classes in a new exception package:

Class Purpose
LicenseDBException Base exception for all LicenseDB errors
LicenseDBConnectionException Thrown when LicenseDB server is unreachable
LicenseDBAuthenticationException Thrown when OAuth2 authentication fails
LicenseDBDataException Thrown when data validation fails

File Structure

rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/licensedb/exception/
├── LicenseDBException.java
├── LicenseDBConnectionException.java
├── LicenseDBAuthenticationException.java
└── LicenseDBDataException.java

Example Usage

try {
    licenses = licenseDBClient.getAllLicenses();
} catch (LicenseDBConnectionException e) {
    log.error("Cannot connect to LicenseDB: {}", e.getMessage());
    return error("LicenseDB service unavailable");
} catch (LicenseDBAuthenticationException e) {
    log.error("OAuth2 auth failed: {}", e.getMessage());
    return error("LicenseDB authentication failed");
} catch (LicenseDBDataException e) {
    log.error("Invalid data from LicenseDB: {}", e.getMessage());
    return error("LicenseDB data validation failed");
}

Testing

  • Files compile without errors
  • Follow SW360 code style
  • EPL-2.0 license headers included
  • No dependencies on other components

Documentation

Each exception class includes Javadoc documentation explaining:

  • When to use the exception
  • Common causes
  • Example usage

Dependencies

None - This is an independent component that does not require other components.

Related

Added custom exception classes for LicenseDB integration error handling:
- LicenseDBException: Base exception class for all LicenseDB errors
- LicenseDBConnectionException: Thrown when LicenseDB server is unreachable
- LicenseDBAuthenticationException: Thrown when OAuth2 authentication fails
- LicenseDBDataException: Thrown when data validation fails

These exceptions provide structured error handling for various failure
scenarios when communicating with the LicenseDB service.

Fixes eclipse-sw360#3893
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add LicenseDB exception handling classes for error management

1 participant