c++: CowException for handling errors/poisoned cows

error_handling
Avril 4 years ago
parent 8f8d738e0e
commit 960f18a6e0
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -28,13 +28,13 @@ Cow::_inner::~_inner() {
cow.poisoned=true; cow.poisoned=true;
} }
Cow::_inner::_inner(size_t sz) : cow(_cow_create_unboxed(sz)){ Cow::_inner::_inner(size_t sz) : cow(_cow_create_unboxed(sz)){
//TODO: Real exception type?
if(UNLIKELY(cow.poisoned)) throw CowException(cow_err()); if(UNLIKELY(cow.poisoned)) throw CowException(cow_err());
} }
Cow::_inner::_inner(cow_t* ptr) : cow(*ptr) Cow::_inner::_inner(cow_t* ptr) : cow(*ptr)
{ {
if(UNLIKELY(cow.poisoned)) throw CowException(cow_err());
free(ptr); free(ptr);
if(UNLIKELY(cow.poisoned)) throw CowException(cow_err());
} }
Cow::Cow(size_t size) : super(std::make_shared<_inner>(size)){} Cow::Cow(size_t size) : super(std::make_shared<_inner>(size)){}

Loading…
Cancel
Save