Skip to content

Commit

Permalink
Feature/capps2/successreturnvalue (#1224)
Browse files Browse the repository at this point in the history
Return success or failure from Group::save, load, loadExternalData.

During Group I/O calls (Group::save, load, loadExternalData), a utility class saves Conduit error handler routines, catches Conduit exceptions, logs them to the Group's DataStore.  The I/O call then returns whether any exceptions have been logged to the DataStore.  User code may directly query the DataStore for the presence of exception messages or the text of the messages themselves.  Code may clear the messages, so that subsequent successful I/O messages will return true.  Code may also append to the DataStore's exception messages.

---------

Co-authored-by: Rich Hornung <hornung1@llnl.gov>
  • Loading branch information
agcapps and rhornung67 committed Jan 23, 2024
1 parent c0a97db commit b89d583
Show file tree
Hide file tree
Showing 7 changed files with 458 additions and 125 deletions.
1 change: 1 addition & 0 deletions src/axom/sidre/core/DataStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ DataStore::DataStore()
, m_buffer_coll(new BufferCollection())
, m_attribute_coll(new AttributeCollection())
, m_need_to_finalize_slic(false)
, m_conduit_errors()
{
if(!axom::slic::isInitialized())
{
Expand Down
29 changes: 29 additions & 0 deletions src/axom/sidre/core/DataStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,32 @@ class DataStore
*/
const Group* getRoot() const { return m_RootGroup; };

//@{
/*! @name Methods to query and clear Conduit I/O flags and exception messages.
*
* If an error occurs, the load(), save(), and loadExternalData() methods of
* any Group owned by this DataStore will return false (for I/O failure) and
* subsequent calls will continue to return false until the user clears the
* Conduit errors.
*/

/// Return whether a Conduit error occurred.
bool getConduitErrorOccurred() const { return !m_conduit_errors.empty(); };

/// Return information on any Conduit errors.
std::string getConduitErrors() const { return m_conduit_errors; };

/// Clear any Conduit errors.
void clearConduitErrors() const { m_conduit_errors.clear(); };

/// Append a string to the accumulated Conduit errors.
void appendToConduitErrors(const std::string& mesg) const
{
m_conduit_errors = m_conduit_errors + "\n" + mesg;
};

//@}

public:
//@{
//! @name Methods to query, access, create, and destroy Buffers.
Expand Down Expand Up @@ -540,6 +566,9 @@ class DataStore

/// Flag indicating whether SLIC logging environment was initialized in ctor.
bool m_need_to_finalize_slic;

/// Details of the most recent Conduit error. Length > 0 indicates an error occurred.
mutable std::string m_conduit_errors;
};

} /* end namespace sidre */
Expand Down

0 comments on commit b89d583

Please sign in to comment.