ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Member Functions | List of all members
version_conflict_exception Class Reference

Exception thrown when an optimistic locking version conflict occurs. More...

#include <version_conflict_exception.hpp>

Inherits exception, and exception.

Collaboration diagram for version_conflict_exception:
Collaboration graph

Public Member Functions

 version_conflict_exception (std::string_view entity_type, std::string_view entity_id, int expected_version, int actual_version)
 Constructs a version conflict exception with detailed information.
 
 version_conflict_exception (std::string_view message="")
 Constructs a version conflict exception with a custom message.
 
const char * what () const noexcept override
 
const std::optional< std::string > & entity_type () const noexcept
 
const std::optional< std::string > & entity_id () const noexcept
 
std::optional< int > expected_version () const noexcept
 
std::optional< int > actual_version () const noexcept
 

Detailed Description

Exception thrown when an optimistic locking version conflict occurs.

This exception indicates that an entity update failed because the version provided by the client does not match the current version in the database. This typically happens when another client has modified the entity between the time it was read and the time the update was attempted.

Constructor & Destructor Documentation

◆ version_conflict_exception() [1/2]

version_conflict_exception ( std::string_view  entity_type,
std::string_view  entity_id,
int  expected_version,
int  actual_version 
)

Constructs a version conflict exception with detailed information.

Parameters
entity_typeThe type of entity that had the version conflict
entity_idThe identifier of the entity
expected_versionThe version the client expected (sent with update)
actual_versionThe current version in the database

◆ version_conflict_exception() [2/2]

version_conflict_exception ( std::string_view  message = "")
explicit

Constructs a version conflict exception with a custom message.

When using this constructor, entity_type, entity_id, expected_version, and actual_version will be std::nullopt, indicating that this detailed information is not available.