sun::support::SunError

sun::support::SunError

class · Source (opens in a new tab)

class sun::support::SunError : public std::exception

Custom error type for Sun compiler errors.

Inherits

  • std::exception (public)

Public Functions

SunError

public · function · Source (opens in a new tab)

sun::support::SunError::SunError(Kind kind, const std::string &message, std::optional< Position > loc=std::nullopt, const std::string &sourceLine="", const std::string &prevSourceLine="")

Creates a compiler exception with its diagnostic category and source context.

Related: Kind, Position

addRelated

public · function · Source (opens in a new tab)

void sun::support::SunError::addRelated(const std::string &message, const Position &location, RelatedDiagnostic::Level level)

Record another place this error points at.

It joins the printed message, rendered like any other diagnostic.

Related: Position, RelatedDiagnostic::Level

getKind

public · function · Source (opens in a new tab)

Kind sun::support::SunError::getKind() const

Returns the type category used for semantic checks and dispatch.

Related: Kind

getLabel

public · function · Source (opens in a new tab)

std::string sun::support::SunError::getLabel() const

What the error is called when printed, such as "Parse Error".

getLocation

public · function · Source (opens in a new tab)

const std::optional< Position > & sun::support::SunError::getLocation() const

Returns the source position used for diagnostics.

Related: Position

getMessage

public · function · Source (opens in a new tab)

const std::string & sun::support::SunError::getMessage() const

Returns the message stored by this object.

getRelated

public · function · Source (opens in a new tab)

const std::vector< RelatedDiagnostic > & sun::support::SunError::getRelated() const

Returns the related diagnostic locations.

Related: RelatedDiagnostic

getSourceLine

public · function · Source (opens in a new tab)

const std::string & sun::support::SunError::getSourceLine() const

Returns the source line stored by this object.

what

public · function · Source (opens in a new tab)

const char * sun::support::SunError::what() const noexcept override

Returns the formatted diagnostic message through the exception interface.

Public Enums

Kind

public · enum · Source (opens in a new tab)

enum class sun::support::SunError::Kind

Identifies the compiler stage or rule that produced an error.

Compile

Compile

No documentation comment.

Parse

Parse

No documentation comment.

Type

Type

No documentation comment.

Semantic

Semantic

No documentation comment.

Borrow

Borrow

No documentation comment.

Private Functions

buildFullMessage

private · function · Source (opens in a new tab)

void sun::support::SunError::buildFullMessage()

Combines the error category, message, and source context into a diagnostic.

kindToString

private · function · Source (opens in a new tab)

std::string sun::support::SunError::kindToString() const

Returns the readable category name for this compiler error.

Private Fields

fullMessage_

private · variable · Source (opens in a new tab)

std::string sun::support::SunError::fullMessage_

No documentation comment.

kind_

private · variable · Source (opens in a new tab)

Kind sun::support::SunError::kind_

No documentation comment.

Related: Kind

location_

private · variable · Source (opens in a new tab)

std::optional<Position> sun::support::SunError::location_

No documentation comment.

Related: Position

message_

private · variable · Source (opens in a new tab)

std::string sun::support::SunError::message_

No documentation comment.

prevSourceLine_

private · variable · Source (opens in a new tab)

std::string sun::support::SunError::prevSourceLine_

No documentation comment.

related_

private · variable · Source (opens in a new tab)

std::vector<RelatedDiagnostic> sun::support::SunError::related_

No documentation comment.

Related: RelatedDiagnostic

sourceLine_

private · variable · Source (opens in a new tab)

std::string sun::support::SunError::sourceLine_

No documentation comment.