Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Mantid::API::ScriptRepoException Class Reference

The ScriptRepository class is intended to be used mainly by users, who will want to share and download scripts for their analysis. More...

#include <ScriptRepository.h>

Inheritance diagram for Mantid::API::ScriptRepoException:

Public Member Functions

const std::string & filePath () const
 Returns the file and position where the error was caused.
 
 ScriptRepoException (const std::string &info, const std::string &system, const std::string &file=std::string(), int line=-1)
 
 ScriptRepoException (const std::string &info=std::string("Unknown Exception"))
 default constructor
 
const std::string & systemError () const
 Returns the error description with technical details on the origin and cause.
 
const char * what () const noexcept override
 Returns the message string.
 

Private Attributes

std::string m_filepath
 Path to the file where the error originated, returned by filePath().
 
std::string m_systemError
 Technical description of the error, returned by systemError().
 
std::string m_userInfo
 User-facing message, returned by what().
 

Detailed Description

The ScriptRepository class is intended to be used mainly by users, who will want to share and download scripts for their analysis.

As such, the exceptions raised while operating must provide information that is useful for them to understand what is happening, while the Mantid Team must still be informed of what happened in more technical detail in order to be able to deal with any resulting bugs.

To provide this functionality, ScriptRepoException is used. As a normal std::exception (the default base used throughout the Mantid Project), it allows Mantid to work as usual.

It also extends the usage of the exception by allowing more information to be added. Below are some examples of how to throw exceptions.

// Throw "Unknown Exception"
// After the system sets an errno value, for example EACCES,
// you could tell the user why they cannot download the file.
throw ScriptRepoException(EACCES, "You are not allowed to download scripts. "
"Please contact the administrator");
// For a more serious exception, you could provide the location where it
// was triggered.
throw ScriptRepoException(errno, "Critical Failure", __FILE__, __LINE__)
The ScriptRepository class is intended to be used mainly by users, who will want to share and downloa...

The default ScriptRepoException::what method is used to show the user message, while it is up to whoever is using the ScriptRepository to decide whether to use the technical information available through ScriptRepoException::systemError and ScriptRepoException::filePath.

Definition at line 94 of file ScriptRepository.h.

Constructor & Destructor Documentation

◆ ScriptRepoException() [1/2]

Mantid::API::ScriptRepoException::ScriptRepoException ( const std::string &  info = std::string("Unknown Exception"))
inline

default constructor

Definition at line 98 of file ScriptRepository.h.

◆ ScriptRepoException() [2/2]

Mantid::API::ScriptRepoException::ScriptRepoException ( const std::string &  info,
const std::string &  system,
const std::string &  file = std::string(),
int  line = -1 
)

Definition at line 11 of file ScriptRepository.cpp.

References m_filepath, and std::to_string().

Member Function Documentation

◆ filePath()

const std::string & Mantid::API::ScriptRepoException::filePath ( ) const
inline

Returns the file and position where the error was caused.

Definition at line 111 of file ScriptRepository.h.

◆ systemError()

const std::string & Mantid::API::ScriptRepoException::systemError ( ) const
inline

Returns the error description with technical details on the origin and cause.

Definition at line 109 of file ScriptRepository.h.

Referenced by MantidQt::API::RepoModel::handleExceptions(), and MantidQt::API::ScriptRepositoryView::ScriptRepositoryView().

◆ what()

const char * Mantid::API::ScriptRepoException::what ( ) const
overridenoexcept

Member Data Documentation

◆ m_filepath

std::string Mantid::API::ScriptRepoException::m_filepath
private

Path to the file where the error originated, returned by filePath().

Definition at line 119 of file ScriptRepository.h.

Referenced by ScriptRepoException().

◆ m_systemError

std::string Mantid::API::ScriptRepoException::m_systemError
private

Technical description of the error, returned by systemError().

Definition at line 115 of file ScriptRepository.h.

◆ m_userInfo

std::string Mantid::API::ScriptRepoException::m_userInfo
private

User-facing message, returned by what().

Definition at line 117 of file ScriptRepository.h.

Referenced by what().


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