CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-flywaydb--flyway-core

Database migration tool that enables versioned database schema evolution with simple SQL scripts and Java migrations

Pending
Overview
Eval results
Files

error-handling.mddocs/

Error Handling

Comprehensive exception hierarchy and error reporting system for handling migration failures, validation errors, and operational issues.

Capabilities

Exception Hierarchy

/**
 * Main Flyway exception - base for all Flyway-specific exceptions
 */
public class FlywayException extends RuntimeException {
    public FlywayException(String message);
    public FlywayException(String message, Throwable cause);
    public FlywayException(Throwable cause);
}

/**
 * Exception thrown when Flyway validation fails
 */
public class FlywayValidateException extends FlywayException {
    public FlywayValidateException(ErrorDetails errorDetails, String... validationErrors);
    public ErrorDetails getErrorDetails();
}

/**
 * Exception thrown when statement execution is blocked
 */
public class FlywayBlockStatementExecutionException extends FlywayException {
    public FlywayBlockStatementExecutionException(String message);
}

Error Information

/**
 * Interface for error codes
 */
public interface ErrorCode {
    String getCode();
    String getMessage();
}

/**
 * Core error codes enumeration
 */
public enum CoreErrorCode implements ErrorCode {
    NON_EMPTY_SCHEMA_WITHOUT_SCHEMA_HISTORY_TABLE,
    FAILED_RESOLVING_MIGRATIONS,
    FAILED_VALIDATING_MIGRATIONS,
    VALIDATION_FAILED,
    CHECKSUM_MISMATCH,
    TYPE_MISMATCH,
    DESCRIPTION_MISMATCH;
    
    public String getCode();
    public String getMessage();
}

/**
 * Detailed error information
 */
public interface ErrorDetails {
    ErrorCode getErrorCode();
    String getMessage();
    String getFilename();
    Integer getLineNumber();
}

Usage Examples

// Basic error handling
try {
    flyway.migrate();
} catch (FlywayException e) {
    System.err.println("Migration failed: " + e.getMessage());
    e.printStackTrace();
}

// Validation error handling
try {
    flyway.validate();
} catch (FlywayValidateException e) {
    ErrorDetails details = e.getErrorDetails();
    System.err.println("Validation failed:");
    System.err.println("Error code: " + details.getErrorCode().getCode());
    System.err.println("Message: " + details.getMessage());
    if (details.getFilename() != null) {
        System.err.println("File: " + details.getFilename());
    }
}

// Comprehensive error handling
try {
    MigrateResult result = flyway.migrate();
    System.out.println("Migration successful");
} catch (FlywayValidateException e) {
    // Handle validation errors
    System.err.println("Validation failed: " + e.getMessage());
} catch (FlywayException e) {
    // Handle general Flyway errors
    System.err.println("Flyway operation failed: " + e.getMessage());
} catch (Exception e) {
    // Handle unexpected errors
    System.err.println("Unexpected error: " + e.getMessage());
}

Install with Tessl CLI

npx tessl i tessl/maven-org-flywaydb--flyway-core

docs

callbacks.md

configuration.md

core-operations.md

error-handling.md

index.md

java-migrations.md

migration-info.md

tile.json