version  0.0.1
Defines the C++ API for MsPASS
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. More...
 
 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. More...
 
 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/2]

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.
30  {
31 
32  std::string pretty_name(boost::core::demangle(Texpected));
33  ss<<"Error trying to extract Metadata with key="<<key<<std::endl
34  << "No value associated with this key is set in Metadata object"<<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:109
ErrorSeverity badness
Definition: MsPASSError.h:116

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

◆ MetadataGetError() [2/2]

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.

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

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


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