RStudio Launcher Plugin SDK  1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
Public Member Functions | List of all members
rstudio::launcher_plugins::Error Class Reference

Class which represents an error. More...

#include <Error.hpp>

Inheritance diagram for rstudio::launcher_plugins::Error:
rstudio::launcher_plugins::ErrorLock rstudio::launcher_plugins::Success

Public Member Functions

 Error ()
 Constructor.
 
 Error (const Error &in_other)
 Copy constructor. More...
 
 Error (std::string in_name, int in_code, const ErrorLocation &in_location)
 Constructor. More...
 
 Error (std::string in_name, int in_code, const Error &in_cause, const ErrorLocation &in_location)
 Constructor. More...
 
 Error (std::string in_name, int in_code, std::string in_message, const ErrorLocation &in_location)
 Constructor. More...
 
 Error (std::string in_name, int in_code, std::string in_message, const Error &in_cause, const ErrorLocation &in_location)
 Constructor. More...
 
 ~Error () override=default
 Non-virtual destructor because only Success inherits Error and it will keep Error lightweight.
 
 operator bool () const
 Overloaded operator bool to allow Errors to be treated as boolean values. More...
 
bool operator! () const
 Overloaded operator ! to allow Errors to be treated as boolean values. More...
 
bool operator== (const Error &in_other) const
 Equality operator. Two errors are equal if their codes and names are the same. More...
 
bool operator!= (const Error &in_other) const
 Inequality operator. Two errors are equal if their codes and names are the same. More...
 
void addOrUpdateProperty (const std::string &in_name, const std::string &in_value)
 Add or updates a property of this error. If any properties with the specified name exist, they will all be updated. More...
 
void addOrUpdateProperty (const std::string &in_name, const system::FilePath &in_value)
 Add or updates a property of this error. If any properties with the specified name exist, they will all be updated. More...
 
void addOrUpdateProperty (const std::string &in_name, int in_value)
 Add or updates a property of this error. If any properties with the specified name exist, they will all be updated. More...
 
void addProperty (const std::string &in_name, const std::string &in_value)
 Adds a property of this error. If a property with the same name already exists, a duplicate will be added. More...
 
void addProperty (const std::string &in_name, const system::FilePath &in_value)
 Adds a property of this error. If a property with the same name already exists, a duplicate will be added. More...
 
void addProperty (const std::string &in_name, int in_value)
 Adds a property of this error. If a property with the same name already exists, a duplicate will be added. More...
 
std::string asString () const
 Formats the error as a string. More...
 
bool hasCause () const
 Checks whether this error was caused by a separate error. More...
 
const Optional< Error > & getCause () const
 Gets the error which caused this error. More...
 
int getCode () const
 Gets the error code. More...
 
const ErrorLocationgetLocation () const
 Gets the location where the error occurred. More...
 
const std::string & getMessage () const
 Gets the error message. More...
 
const std::string & getName () const
 Gets the name of the error. More...
 
const ErrorProperties & getProperties () const
 Gets the custom properties of the error. More...
 
std::string getProperty (const std::string &name) const
 Gets a custom property of this error. More...
 
std::string getSummary () const
 Gets the cause of the error. More...
 
bool isExpected () const
 Gets whether this error was expected or not. More...
 
void setExpected ()
 Sets the property that indicates that this error was expected. Errors are unexpected by default; only unexpected errors will be logged. Expected errors can be marked as such to suppress logging of those errors.
 

Detailed Description

Class which represents an error.

This class should not be derived from since it is returned by value throughout the SDK. Instead, create helper functions for each "subclass" of Error that would be desired.

Constructor & Destructor Documentation

◆ Error() [1/5]

rstudio::launcher_plugins::Error::Error ( const Error in_other)

Copy constructor.

Parameters
in_otherThe error to copy.

◆ Error() [2/5]

rstudio::launcher_plugins::Error::Error ( std::string  in_name,
int  in_code,
const ErrorLocation in_location 
)

Constructor.

Parameters
in_nameA contextual or categorical name for the error. (e.g. "RequestNotSupported")
in_codeThe non-zero error code. Note that an error code of zero indicates success. (e.g. 1)
in_locationThe location of the error.

◆ Error() [3/5]

rstudio::launcher_plugins::Error::Error ( std::string  in_name,
int  in_code,
const Error in_cause,
const ErrorLocation in_location 
)

Constructor.

Parameters
in_nameA contextual or categorical name for the error. (e.g. "RequestNotSupported")
in_codeThe non-zero error code. Note that an error code of zero indicates success. (e.g. 1)
in_causeThe error which caused this error.
in_locationThe location of the error.

◆ Error() [4/5]

rstudio::launcher_plugins::Error::Error ( std::string  in_name,
int  in_code,
std::string  in_message,
const ErrorLocation in_location 
)

Constructor.

Parameters
in_nameA contextual or categorical name for the error. (e.g. "RequestNotSupported")
in_codeThe non-zero error code. Note that an error code of zero indicates success. (e.g. 1)
in_messageThe detailed error message. (e.g. "The JobNetworkRequest is not supported by this plugin.")
in_locationThe location of the error.

◆ Error() [5/5]

rstudio::launcher_plugins::Error::Error ( std::string  in_name,
int  in_code,
std::string  in_message,
const Error in_cause,
const ErrorLocation in_location 
)

Constructor.

Parameters
in_nameA contextual or categorical name for the error. (e.g. "RequestNotSupported")
in_codeThe non-zero error code. Note that an error code of zero indicates success. (e.g. 1)
in_messageThe detailed error message. (e.g. "The JobNetworkRequest is not supported by this plugin.")
in_causeThe error which caused this error.
in_locationThe location of the error.

Member Function Documentation

◆ addOrUpdateProperty() [1/3]

void rstudio::launcher_plugins::Error::addOrUpdateProperty ( const std::string &  in_name,
const std::string &  in_value 
)

Add or updates a property of this error. If any properties with the specified name exist, they will all be updated.

Parameters
in_nameThe name of the property to add or update.
in_valueThe new value of the property.

◆ addOrUpdateProperty() [2/3]

void rstudio::launcher_plugins::Error::addOrUpdateProperty ( const std::string &  in_name,
const system::FilePath in_value 
)

Add or updates a property of this error. If any properties with the specified name exist, they will all be updated.

Parameters
in_nameThe name of the property to add or update.
in_valueThe new value of the property.

◆ addOrUpdateProperty() [3/3]

void rstudio::launcher_plugins::Error::addOrUpdateProperty ( const std::string &  in_name,
int  in_value 
)

Add or updates a property of this error. If any properties with the specified name exist, they will all be updated.

Parameters
in_nameThe name of the property to add or update.
in_valueThe new value of the property.

◆ addProperty() [1/3]

void rstudio::launcher_plugins::Error::addProperty ( const std::string &  in_name,
const std::string &  in_value 
)

Adds a property of this error. If a property with the same name already exists, a duplicate will be added.

Parameters
in_nameThe name of the property to add or update.
in_valueThe new value of the property.

◆ addProperty() [2/3]

void rstudio::launcher_plugins::Error::addProperty ( const std::string &  in_name,
const system::FilePath in_value 
)

Adds a property of this error. If a property with the same name already exists, a duplicate will be added.

Parameters
in_nameThe name of the property to add or update.
in_valueThe new value of the property.

◆ addProperty() [3/3]

void rstudio::launcher_plugins::Error::addProperty ( const std::string &  in_name,
int  in_value 
)

Adds a property of this error. If a property with the same name already exists, a duplicate will be added.

Parameters
in_nameThe name of the property to add or update.
in_valueThe new value of the property.

◆ asString()

std::string rstudio::launcher_plugins::Error::asString ( ) const

Formats the error as a string.

Returns
The error formatted as a string.

◆ getCause()

const Optional<Error>& rstudio::launcher_plugins::Error::getCause ( ) const

Gets the error which caused this error.

Returns
The error which caused this error.

◆ getCode()

int rstudio::launcher_plugins::Error::getCode ( ) const

Gets the error code.

Returns
The error code.

◆ getLocation()

const ErrorLocation& rstudio::launcher_plugins::Error::getLocation ( ) const

Gets the location where the error occurred.

Returns
The location where the error occurred.

◆ getMessage()

const std::string& rstudio::launcher_plugins::Error::getMessage ( ) const

Gets the error message.

Returns
The error message.

◆ getName()

const std::string& rstudio::launcher_plugins::Error::getName ( ) const

Gets the name of the error.

Returns
The name of the error.

◆ getProperties()

const ErrorProperties& rstudio::launcher_plugins::Error::getProperties ( ) const

Gets the custom properties of the error.

Returns
The custom properties of this error.

◆ getProperty()

std::string rstudio::launcher_plugins::Error::getProperty ( const std::string &  name) const

Gets a custom property of this error.

Parameters
nameThe name of the property to retrieve.
Returns
The value of the specified property, if it exists; empty string otherwise.

◆ getSummary()

std::string rstudio::launcher_plugins::Error::getSummary ( ) const

Gets the cause of the error.

Returns
The cause of the error.

◆ hasCause()

bool rstudio::launcher_plugins::Error::hasCause ( ) const

Checks whether this error was caused by a separate error.

Returns
True if the error has an associated cause.

◆ isExpected()

bool rstudio::launcher_plugins::Error::isExpected ( ) const

Gets whether this error was expected or not.

Returns
True if this error was expected; false otherwise.

◆ operator bool()

rstudio::launcher_plugins::Error::operator bool ( ) const
explicit

Overloaded operator bool to allow Errors to be treated as boolean values.

Returns
True if there is an error; false otherwise.

◆ operator!()

bool rstudio::launcher_plugins::Error::operator! ( ) const

Overloaded operator ! to allow Errors to be treated as boolean values.

Returns
True if there is not an error; false otherwise.

◆ operator!=()

bool rstudio::launcher_plugins::Error::operator!= ( const Error in_other) const

Inequality operator. Two errors are equal if their codes and names are the same.

Parameters
in_otherThe error to compare with this error.
Returns
True if in_other is not equal to this error; false otherwise.

◆ operator==()

bool rstudio::launcher_plugins::Error::operator== ( const Error in_other) const

Equality operator. Two errors are equal if their codes and names are the same.

Parameters
in_otherThe error to compare with this error.
Returns
True if in_other is equal to this error; false otherwise.

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