Lightweight 0.20260303.0
Loading...
Searching...
No Matches
Lightweight::SqlMigration::MigrationException Class Reference

#include <SqlMigration.hpp>

Inherits Lightweight::SqlException.

Public Types

enum class  Operation : std::uint8_t { Apply , Revert }
 Whether the failure happened while applying (Up) or reverting (Down). More...
 

Public Member Functions

 MigrationException (Operation operation, MigrationTimestamp timestamp, std::string title, std::size_t stepIndex, std::string failedSql, SqlErrorInfo driverError)
 
Operation GetOperation () const noexcept
 Whether the failure occurred while applying or reverting.
 
MigrationTimestamp GetMigrationTimestamp () const noexcept
 Timestamp of the failing migration.
 
std::string const & GetMigrationTitle () const noexcept
 Human-readable title of the failing migration.
 
std::size_t GetStepIndex () const noexcept
 Zero-based step index inside the plan of the failing migration.
 
std::string const & GetFailedSql () const noexcept
 The exact SQL statement that the driver rejected.
 
std::string const & GetDriverMessage () const noexcept
 

Detailed Description

Exception thrown when applying or reverting a single migration fails.

Carries structured diagnostic context so callers (CLI, GUI) can render the which migration, which step, which SQL statement and the underlying driver error as separate fields instead of parsing one opaque message string.

Definition at line 64 of file SqlMigration.hpp.

Member Enumeration Documentation

◆ Operation

Whether the failure happened while applying (Up) or reverting (Down).

Definition at line 68 of file SqlMigration.hpp.

Constructor & Destructor Documentation

◆ MigrationException()

Lightweight::SqlMigration::MigrationException::MigrationException ( Operation  operation,
MigrationTimestamp  timestamp,
std::string  title,
std::size_t  stepIndex,
std::string  failedSql,
SqlErrorInfo  driverError 
)

Constructs a migration exception that wraps a driver error with the migration identity and the exact SQL statement that failed.

Parameters
operationWhether the failure happened during apply or revert.
timestampThe migration that failed.
titleHuman-readable migration title.
stepIndexZero-based step index inside the migration plan.
failedSqlThe SQL statement that produced the driver error.
driverErrorThe ODBC-level error info as received from the driver.

Member Function Documentation

◆ GetOperation()

Operation Lightweight::SqlMigration::MigrationException::GetOperation ( ) const
inlinenoexcept

Whether the failure occurred while applying or reverting.

Definition at line 91 of file SqlMigration.hpp.

◆ GetMigrationTimestamp()

MigrationTimestamp Lightweight::SqlMigration::MigrationException::GetMigrationTimestamp ( ) const
inlinenoexcept

Timestamp of the failing migration.

Definition at line 96 of file SqlMigration.hpp.

◆ GetMigrationTitle()

std::string const & Lightweight::SqlMigration::MigrationException::GetMigrationTitle ( ) const
inlinenoexcept

Human-readable title of the failing migration.

Definition at line 101 of file SqlMigration.hpp.

◆ GetStepIndex()

std::size_t Lightweight::SqlMigration::MigrationException::GetStepIndex ( ) const
inlinenoexcept

Zero-based step index inside the plan of the failing migration.

Definition at line 106 of file SqlMigration.hpp.

◆ GetFailedSql()

std::string const & Lightweight::SqlMigration::MigrationException::GetFailedSql ( ) const
inlinenoexcept

The exact SQL statement that the driver rejected.

Definition at line 111 of file SqlMigration.hpp.

◆ GetDriverMessage()

std::string const & Lightweight::SqlMigration::MigrationException::GetDriverMessage ( ) const
inlinenoexcept

Raw driver error message, without the migration context prefix that what() and info().message decorate it with.

Definition at line 117 of file SqlMigration.hpp.


The documentation for this class was generated from the following file: