RStudio Launcher Plugin SDK
1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
|
24 #ifndef LAUNCHER_PLUGINS_ERROR_HPP
25 #define LAUNCHER_PLUGINS_ERROR_HPP
28 #include <system_error>
35 namespace launcher_plugins {
103 ErrorLocation(
const char* in_function,
const char* in_file,
long in_line);
135 const std::string&
getFile()
const;
160 PRIVATE_IMPL(m_impl);
166 typedef std::vector<std::pair<std::string, std::string> > ErrorProperties;
217 Error(std::string in_name,
int in_code, std::string in_message,
const ErrorLocation& in_location);
229 Error(std::string in_name,
231 std::string in_message,
232 const Error& in_cause,
238 ~Error()
override =
default;
245 explicit operator bool()
const;
305 void addProperty(
const std::string& in_name,
const std::string& in_value);
321 void addProperty(
const std::string& in_name,
int in_value);
370 const std::string&
getName()
const;
386 std::string
getProperty(
const std::string& name)
const;
421 bool isError()
const;
424 PRIVATE_IMPL_SHARED(m_impl);
454 std::ostream& operator<<(std::ostream& io_ostream,
const Error& in_error);
464 Error systemError(
int in_code,
const ErrorLocation& in_location);
474 Error systemError(
const std::error_code& in_code,
const ErrorLocation& in_location);
484 Error systemError(
const std::system_error& in_error,
const ErrorLocation& in_location);
495 Error systemError(
int in_code,
const Error& in_cause,
const ErrorLocation& in_location);
506 Error systemError(
const std::error_code& in_code,
const Error& in_cause,
const ErrorLocation& in_location);
517 Error systemError(
const std::system_error& in_error,
const Error& in_cause,
const ErrorLocation& in_location);
529 Error systemError(
int in_code,
const std::string& in_description,
const ErrorLocation& in_location);
541 Error systemError(
const std::error_code& in_code,
const std::string& in_description,
const ErrorLocation& in_location);
554 const std::system_error& in_error,
555 const std::string& in_description,
556 const ErrorLocation& in_location);
571 const std::string& in_description,
572 const Error& in_cause,
573 const ErrorLocation& in_location);
587 const std::error_code& in_code,
588 const std::string& in_description,
589 const Error& in_cause,
590 const ErrorLocation& in_location);
604 const std::system_error& in_error,
605 const std::string& in_description,
606 const Error& in_cause,
607 const ErrorLocation& in_location);
618 Error systemCallError(
619 const std::string& in_function,
621 const ErrorLocation& in_location);
633 Error systemCallError(
634 const std::string& in_function,
636 const std::string& in_message,
637 const ErrorLocation& in_location);
650 Error unknownError(
const std::string& in_message,
const ErrorLocation& in_location);
663 Error unknownError(
const std::string& in_message,
const Error& in_cause,
const ErrorLocation& in_location);
668 #ifdef STRIPPED_FILENAME
669 #define ERROR_LOCATION rstudio::launcher_plugins::ErrorLocation( \
670 __FUNCTION__, STRIPPED_FILENAME, __LINE__)
672 #define ERROR_LOCATION rstudio::launcher_plugins::ErrorLocation( \
673 __FUNCTION__, __FILE__, __LINE__)
676 #define CATCH_UNEXPECTED_EXCEPTION \
677 catch(const std::exception& e) \
679 rstudio::launcher_plugins::logging::logErrorMessage(std::string("Unexpected exception: ") + \
680 e.what(), ERROR_LOCATION); \
684 rstudio::launcher_plugins::logging::logErrorMessage("Unknown exception", ERROR_LOCATION); \
const std::string & getName() const
Gets the name of the error.
Class which represents a path on the system. May be any type of file (e.g. directory,...
Definition: FilePath.hpp:77
ErrorLocation()
Default constructor.
Class which represents the location of an error.
Definition: Error.hpp:74
Success()
Constructor.
Definition: Error.hpp:443
bool isExpected() const
Gets whether this error was expected or not.
bool operator!=(const Error &in_other) const
Inequality operator. Two errors are equal if their codes and names are the same.
bool hasCause() const
Checks whether this error was caused by a separate error.
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 a...
void setExpected()
Sets the property that indicates that this error was expected. Errors are unexpected by default; only...
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,...
std::string asString() const
Formats the error as a string.
Class which represents a successful operation (i.e. no error).
Definition: Error.hpp:437
std::string getSummary() const
Gets the cause of the error.
const std::string & getMessage() const
Gets the error message.
ErrorLocation & operator=(const ErrorLocation &in_other)
Assignment operator.
bool operator==(const ErrorLocation &in_location) const
Equality comparison operator.
const ErrorProperties & getProperties() const
Gets the custom properties of the error.
A class which can be derived from in order to prevent child classes from being derived from further.
Definition: Error.hpp:49
long getLine() const
Gets the line where the error occurred.
std::string getProperty(const std::string &name) const
Gets a custom property of this error.
bool hasLocation() const
Checks whether the location is set.
Class which represents an error.
Definition: Error.hpp:174
int getCode() const
Gets the error code.
const std::string & getFile() const
Gets the file where the error occurred.
bool operator==(const Error &in_other) const
Equality operator. Two errors are equal if their codes and names are the same.
const Optional< Error > & getCause() const
Gets the error which caused this error.
Container class which represents a value that may or may not be set.
Definition: Optional.hpp:38
const std::string & getFunction() const
Gets the function where the error occurred.
std::string asString() const
Formats the error location as a string.
~Error() override=default
Non-virtual destructor because only Success inherits Error and it will keep Error lightweight.
bool operator!() const
Overloaded operator ! to allow Errors to be treated as boolean values.
const ErrorLocation & getLocation() const
Gets the location where the error occurred.