CppCrate 0.1
Public Types | Public Member Functions | List of all members
CppCrate::BlobResult Class Reference

Public Types

enum  ErrorType { HttpErrorType, CrateErrorType, OtherErrorType }
 

Public Member Functions

 BlobResult ()
 
 BlobResult (const std::string &error, ErrorType type)
 
const std::string & errorString () const
 
ErrorType errorType () const
 
bool hasError () const
 
bool isCrateError () const
 
const std::string & key () const
 
 operator bool () const
 
void setErrorString (const std::string &error, ErrorType type)
 
void setKey (const std::string &key)
 

Detailed Description

The class BlobResult encapsulates Crate's HTTP endpoint reply of a blob operation.

A blob operation can fail because of a network error or an error issued by Crate. To determine if a blob operation was successful you can investigate the result the Client returns:

BlobResult result = client.anyBlobOperation();
if (result) {
// The operation succeeded.
} else {
if (result.isCrateError()) {
// The operation was denied by Crate
} else {
// A network or client related error occurred.
}
}

Member Enumeration Documentation

◆ ErrorType

Describes the blob operation's error type.

Enumerator
HttpErrorType 

An error due to connection problems.

CrateErrorType 

An error issued by Crate.

OtherErrorType 

An error of unknown source.

Constructor & Destructor Documentation

◆ BlobResult() [1/2]

CppCrate::BlobResult::BlobResult ( )

Constructs an empty result.

◆ BlobResult() [2/2]

CppCrate::BlobResult::BlobResult ( const std::string &  error,
BlobResult::ErrorType  type 
)

Constructs a result with the error string error and the type type.

Member Function Documentation

◆ errorString()

const std::string & CppCrate::BlobResult::errorString ( ) const

Returns the error string.

◆ errorType()

BlobResult::ErrorType CppCrate::BlobResult::errorType ( ) const

Returns the error type.

See also
BlobResult::ErrorType

◆ hasError()

bool CppCrate::BlobResult::hasError ( ) const

Returns whether the result has an error.

◆ isCrateError()

bool CppCrate::BlobResult::isCrateError ( ) const

Returns whether the error is Crate related.

See also
BlobResult::ErrorType

◆ key()

const std::string & CppCrate::BlobResult::key ( ) const

Returns the key of the processed blob.

◆ operator bool()

CppCrate::BlobResult::operator bool ( ) const
explicit

Returns whether the result is valid.

◆ setErrorString()

void CppCrate::BlobResult::setErrorString ( const std::string &  error,
ErrorType  type 
)

Sets the error string to error and it's type to type.

◆ setKey()

void CppCrate::BlobResult::setKey ( const std::string &  key)

Sets the key of the processed blob to key.