libqasm
library for handling cQASM files
Public Member Functions | Public Attributes | List of all members
cqasm::error::AnalysisError Class Reference

Exception used for analysis errors. More...

Public Member Functions

 AnalysisError (std::string &&message="", const tree::Annotatable *node=nullptr)
 Constructs a new error. More...
 
void context (const tree::Annotatable &node)
 Sets the context of this error to the SourceLocation annotation of the given node, if the error doesn't already have such a context. More...
 
const std::string & get_message () const
 Constructs the message string. More...
 
const char * what () const noexcept override
 Returns the message exception-style. More...
 

Public Attributes

std::ostringstream message
 The stringstream used to construct the message. More...
 
std::unique_ptr< annotations::SourceLocationlocation
 Attached location in the source file, if any. More...
 

Detailed Description

Exception used for analysis errors.

Contains a message in the form of an std::ostringstream that can be appended to or otherwise modified even after the initial throw to add information, as well as an optional source location object.

Definition at line 27 of file cqasm-error.hpp.

#include <cqasm-error.hpp>

Inheritance diagram for cqasm::error::AnalysisError:
Inheritance graph
[legend]
Collaboration diagram for cqasm::error::AnalysisError:
Collaboration graph
[legend]

Constructor & Destructor Documentation

◆ AnalysisError()

cqasm::error::AnalysisError::AnalysisError ( std::string &&  message = "",
const tree::Annotatable node = nullptr 
)
explicit

Constructs a new error.

If node is a non-null annotatable with a location node, its location information is attached.

Definition at line 14 of file cqasm-error.cpp.

Member Function Documentation

◆ context()

void cqasm::error::AnalysisError::context ( const tree::Annotatable node)

Sets the context of this error to the SourceLocation annotation of the given node, if the error doesn't already have such a context.

If it does, this is no-op.

Definition at line 29 of file cqasm-error.cpp.

◆ get_message()

const std::string & cqasm::error::AnalysisError::get_message ( ) const

Constructs the message string.

Definition at line 40 of file cqasm-error.cpp.

◆ what()

const char * cqasm::error::AnalysisError::what ( ) const
overridenoexcept

Returns the message exception-style.

Definition at line 54 of file cqasm-error.cpp.

Member Data Documentation

◆ message

std::ostringstream cqasm::error::AnalysisError::message

The stringstream used to construct the message.

Additional information can be appended after construction.

Definition at line 41 of file cqasm-error.hpp.

◆ location

std::unique_ptr<annotations::SourceLocation> cqasm::error::AnalysisError::location

Attached location in the source file, if any.

Definition at line 46 of file cqasm-error.hpp.


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