CGRAOmp  0.1
Public Member Functions | Static Public Attributes | Private Types | Private Attributes | List of all members
CGRAOmp::ModelError Class Reference

A custom error used to notice the specified configuration file is invalid. More...

#include <CGRAModel.hpp>

Inheritance diagram for CGRAOmp::ModelError:

Public Member Functions

 ModelError (StringRef filename, StringRef missed_key)
 Construct a new ModelError when missing a required item. More...
 
 ModelError (StringRef filename, StringRef key, StringRef exptected_type, json::Value *v=nullptr)
 Construct a new ModelError when unexpected value type is specified. More...
 
 ModelError (StringRef filename, std::pair< StringRef, StringRef > config)
 Construct a new ModelError when not implemented configuration is specified. More...
 
 ModelError (StringRef filename, StringRef key, StringRef val, ArrayRef< StringRef > list)
 Construct a new ModelError when a value is invalid for the specified key. More...
 
void setRegion (StringRef region_str)
 set a region where parse error ocurrs More...
 
std::error_code convertToErrorCode () const override
 
void log (raw_ostream &OS) const override
 
bool isMissingKey ()
 check if the error cause if due to missing key More...
 

Static Public Attributes

static char ID = 0
 

Private Types

enum  ErrorType { ErrorType::MissingKey, ErrorType::InvalidDataType, ErrorType::InvalidValue, ErrorType::NoImplemented }
 Type of error cause. More...
 

Private Attributes

ErrorType errtype
 
std::string json_val = ""
 
StringRef filename
 
StringRef error_key
 
std::string error_val
 
StringRef exptected_type
 
StringRef region = ""
 
SmallVector< StringRef > valid_values
 

Detailed Description

A custom error used to notice the specified configuration file is invalid.

Member Enumeration Documentation

◆ ErrorType

enum CGRAOmp::ModelError::ErrorType
strongprivate

Type of error cause.

Enumerator
MissingKey 

missing a required item

InvalidDataType 

specified value is an invalid data type

InvalidValue 

specified value is not valid configuration

NoImplemented 

currently not implemented

Constructor & Destructor Documentation

◆ ModelError() [1/4]

CGRAOmp::ModelError::ModelError ( StringRef  filename,
StringRef  missed_key 
)
inline

Construct a new ModelError when missing a required item.

Parameters
filenamefilename of the parsed configration file
missed_keykey string of missing item

◆ ModelError() [2/4]

CGRAOmp::ModelError::ModelError ( StringRef  filename,
StringRef  key,
StringRef  exptected_type,
json::Value *  v = nullptr 
)
inline

Construct a new ModelError when unexpected value type is specified.

Parameters
filenamefilename of the parsed configration file
keykey string containing invalid type of value
exptected_typethe expected type of string
v(optional) the invalid json::Value instance

◆ ModelError() [3/4]

CGRAOmp::ModelError::ModelError ( StringRef  filename,
std::pair< StringRef, StringRef >  config 
)
inline

Construct a new ModelError when not implemented configuration is specified.

Parameters
filenamefilename of the parsed configration file
configa pair of key and value string for the configuration

◆ ModelError() [4/4]

ModelError::ModelError ( StringRef  filename,
StringRef  key,
StringRef  val,
ArrayRef< StringRef >  list 
)

Construct a new ModelError when a value is invalid for the specified key.

Parameters
filenamefilename of the parsed configration file
keykey string containing invalid value
valthe invalid value string
listlist of valid values

Member Function Documentation

◆ convertToErrorCode()

std::error_code CGRAOmp::ModelError::convertToErrorCode ( ) const
inlineoverride

◆ isMissingKey()

bool CGRAOmp::ModelError::isMissingKey ( )
inline

check if the error cause if due to missing key

Returns
true in the case of missing key
false otherwise

◆ log()

void ModelError::log ( raw_ostream &  OS) const
override

◆ setRegion()

void CGRAOmp::ModelError::setRegion ( StringRef  region_str)
inline

set a region where parse error ocurrs

Parameters
region_stra string of region info for error message

Member Data Documentation

◆ error_key

StringRef CGRAOmp::ModelError::error_key
private

◆ error_val

std::string CGRAOmp::ModelError::error_val
private

◆ errtype

ErrorType CGRAOmp::ModelError::errtype
private

◆ exptected_type

StringRef CGRAOmp::ModelError::exptected_type
private

◆ filename

StringRef CGRAOmp::ModelError::filename
private

◆ ID

char ModelError::ID = 0
static

◆ json_val

std::string CGRAOmp::ModelError::json_val = ""
private

◆ region

StringRef CGRAOmp::ModelError::region = ""
private

◆ valid_values

SmallVector<StringRef> CGRAOmp::ModelError::valid_values
private

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