P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::ErrorMessage Struct Reference

#include <error_message.h>

Public Types

enum class  MessageType : std::size_t { None , Error , Warning , Info }
 

Public Member Functions

 ErrorMessage ()
 Used by errorWithSuffix.
 
 ErrorMessage (MessageType type, std::string prefix, std::string message, const std::vector< Util::SourceInfo > &locations, std::string suffix)
 
 ErrorMessage (MessageType type, std::string prefix, std::string suffix)
 
 ErrorMessage (std::string prefix, Util::SourceInfo info, std::string suffix)
 
std::string getPrefix () const
 
std::string toString () const
 

Public Attributes

std::vector< Util::SourceInfolocations = {}
 Particular formatted message.
 
std::string message
 Typically error/warning type from catalog.
 
std::string prefix
 
std::string suffix
 Relevant source locations for this error.
 
MessageType type = MessageType::None
 

Detailed Description

Structure populated via error_helper functions

Typically, calls to P4::error/P4::warning have many parameters, some of them might have SourceInfo attribute. P4::error_helper parse those parameters, format parameters to output message and extracts SourceInfo wherever possible.

Populated structure can be serialized to canonical error message with toString() method.

This structure is mainly used inside ErrorReporter, but some uses invoke P4::error_helper directly and those uses need to call toString() on returned object.