version  0.0.1
Defines the C++ API for MsPASS
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
mspass::utility::MetadataGetError Class Reference

Error thrown when get operators fail. More...

#include <Metadata.h>

Inheritance diagram for mspass::utility::MetadataGetError:
mspass::utility::MsPASSError

Public Member Functions

 MetadataGetError (const std::string key, const char *Texpected)
 
 MetadataGetError (const char *boostmessage, const std::string key, const char *Texpected, const char *Tactual)
 Constructor called when type requested does not match contents.
 
 MetadataGetError (const MetadataGetError &parent)
 
MetadataGetError operator= (const MetadataGetError &parent)
 
- Public Member Functions inherited from mspass::utility::MsPASSError
 MsPASSError ()
 
 MsPASSError (const std::string mess, const char *howbad)
 Construct from a std::string with badness defined by keywords in a string.
 
 MsPASSError (const std::string mess, const ErrorSeverity s=ErrorSeverity::Invalid)
 
 MsPASSError (const char *mess, const ErrorSeverity s)
 
void log_error ()
 
void log_error (std::ostream &ofs)
 
const char * what () const noexcept
 
ErrorSeverity severity () const
 

Public Attributes

std::stringstream ss
 

Additional Inherited Members

- Protected Attributes inherited from mspass::utility::MsPASSError
std::string message
 
ErrorSeverity badness
 

Detailed Description

Error thrown when get operators fail.

This is a convenience class used to construct a more informative set of errors when get operations fail.

Constructor & Destructor Documentation

◆ MetadataGetError() [1/4]

mspass::utility::MetadataGetError::MetadataGetError ( )
inline
25 : MsPASSError() {}; // seems necessary to not default this with gcc
MsPASSError()
Definition MsPASSError.h:43

◆ MetadataGetError() [2/4]

mspass::utility::MetadataGetError::MetadataGetError ( const std::string  key,
const char *  Texpected 
)
inline

Constructor called when a key is not found in the Metadata.

Parameters
Texpectedis the type name (return of typeid name method) trying to extract.
29 {
30
31 std::string pretty_name(boost::core::demangle(Texpected));
32 ss << "Error trying to extract Metadata with key=" << key << std::endl
33 << "No value associated with this key is set in Metadata object"
34 << std::endl
35 << "Expected an entry of type=" << pretty_name << std::endl;
36 message = ss.str();
37 badness = ErrorSeverity::Suspect;
38 };
std::string message
Definition MsPASSError.h:108
ErrorSeverity badness
Definition MsPASSError.h:110

References mspass::utility::MsPASSError::badness, and mspass::utility::MsPASSError::message.

◆ MetadataGetError() [3/4]

mspass::utility::MetadataGetError::MetadataGetError ( const char *  boostmessage,
const std::string  key,
const char *  Texpected,
const char *  Tactual 
)
inline

Constructor called when type requested does not match contents.

This implementation uses a pickle style map container where the contents of the map can by any type. We use boost::any to provide sanity checks on types. This is creates the error message thrown when the type of the return does not match the type requested.

46 {
47 ss << "Error in Metadata get method. Type mismatch in attem to get "
48 << "data with key=" << key << std::endl
49 << "boost::any bad_any_cast wrote this message: " << std::endl
50 << boostmessage << std::endl;
51 std::string name_e(boost::core::demangle(Texpected));
52 ss << "Trying to convert to data of type=" << name_e << std::endl;
53 std::string name_a(boost::core::demangle(Tactual));
54 ss << "Actual entry has type=" << name_a << std::endl;
55 message = ss.str();
56 badness = ErrorSeverity::Suspect;
57 };

References mspass::utility::MsPASSError::badness, and mspass::utility::MsPASSError::message.

◆ MetadataGetError() [4/4]

mspass::utility::MetadataGetError::MetadataGetError ( const MetadataGetError parent)
inline
58 {
59 message = parent.message;
60 badness = parent.badness;
61 };

Member Function Documentation

◆ operator=()

MetadataGetError mspass::utility::MetadataGetError::operator= ( const MetadataGetError parent)
inline
62 {
63 if (this != &parent) {
64 message = parent.message;
65 badness = parent.badness;
66 }
67 return *this;
68 };

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