Loading...
Searching...
No Matches
UsdValidationError Class Reference

UsdValidationError is an entity returned by a validation task, which is associated with a UsdValidationValidator. More...

#include <error.h>

Public Member Functions

USDVALIDATION_API UsdValidationError ()
 A default constructed UsdValidationError signifies no error.
 
USDVALIDATION_API UsdValidationError (const TfToken &name, const UsdValidationErrorType &errorType, const UsdValidationErrorSites &errorSites, const std::string &errorMsg, const VtValue &metadata=VtValue())
 Instantiate a ValidationError by providing its name, errorType, errorSites and an errorMsg.
 
bool operator== (const UsdValidationError &other) const
 
bool operator!= (const UsdValidationError &other) const
 
const TfTokenGetName () const &
 Returns the name token of the UsdValidationError.
 
TfToken GetName () &&
 Returns the name token of the UsdValidationError by-value.
 
UsdValidationErrorType GetType () const
 Returns the UsdValidationErrorType associated with this UsdValidationError.
 
const UsdValidationErrorSites & GetSites () const &
 Returns the UsdValidationErrorSite associated with this UsdValidationError.
 
UsdValidationErrorSites GetSites () &&
 Returns the UsdValidationErrorSite associated with this UsdValidationError by-value.
 
const UsdValidationValidatorGetValidator () const
 Returns the UsdValidationValidator that reported this error.
 
const std::string & GetMessage () const
 Returns the message associated with this UsdValidationError.
 
const VtValueGetMetadata () const
 Returns the metadata associated with this UsdValidationError.
 
USDVALIDATION_API TfToken GetIdentifier () const
 An identifier for the error constructed from the validator name this error was generated from and its name.
 
USDVALIDATION_API std::string GetErrorAsString () const
 Returns UsdValidationErrorType and ErrorMessage concatenated as a string.
 
bool HasNoError () const
 Returns true if UsdValidationErrorType is UsdValidationErrorType::None, false otherwise.
 
USDVALIDATION_API const std::vector< const UsdValidationFixer * > GetFixers () const
 Return a vector of fixers associated with this Validator.
 
USDVALIDATION_API const UsdValidationFixerGetFixerByName (const TfToken &name) const
 Return an immutable fixer given its name if it exists, else return nullptr.
 
USDVALIDATION_API const std::vector< const UsdValidationFixer * > GetFixersByErrorName () const
 Return a vector of immutable fixers catering to a specific errorName.
 
USDVALIDATION_API const UsdValidationFixerGetFixerByNameAndErrorName (const TfToken &name) const
 Return an immutable fixer given its name and catering to a specific error name if it exists, else return nullptr.
 
USDVALIDATION_API const std::vector< const UsdValidationFixer * > GetFixersByKeywords (const TfTokenVector &keywords) const
 Return a vector of immutable fixers catering to any of the given keywords.
 

Friends

class UsdValidationValidator
 

Detailed Description

UsdValidationError is an entity returned by a validation task, which is associated with a UsdValidationValidator.

A UsdValidationError instance contains important information, like:

  • Name - A name the validator writer provided for the error. This is then used to construct an identifier for the error.
  • UsdValidationErrorType - severity of an error,
  • UsdValidationErrorSites - on what sites validationError was reported by a validation task,
  • Message - Message providing more information associated with the error. Such a message is provided by the validator writer, when providing implementation for the validation task function.

UsdValidationError instances are typically created by the validation task functions, and returned as part of the vector of errors from a call to UsdValidationValidator::Validate() function.

A default constructed UsdValidationError instance signifies no error.

A UsdValidationError instance contains a pointer to the UsdValidationValidator that generated it, which can be retrieved using GetValidator() method.

A UsdValidationError instance can also provide access to the fixers associated with the validator that generated it, which can be retrieved using various GetFixer*() methods.

Definition at line 236 of file error.h.

Constructor & Destructor Documentation

◆ UsdValidationError() [1/2]

USDVALIDATION_API UsdValidationError ( )

A default constructed UsdValidationError signifies no error.

◆ UsdValidationError() [2/2]

USDVALIDATION_API UsdValidationError ( const TfToken name,
const UsdValidationErrorType errorType,
const UsdValidationErrorSites &  errorSites,
const std::string &  errorMsg,
const VtValue metadata = VtValue() 
)

Instantiate a ValidationError by providing its name, errorType, errorSites and an errorMsg.

Member Function Documentation

◆ GetErrorAsString()

USDVALIDATION_API std::string GetErrorAsString ( ) const

Returns UsdValidationErrorType and ErrorMessage concatenated as a string.

◆ GetFixerByName()

USDVALIDATION_API const UsdValidationFixer * GetFixerByName ( const TfToken name) const

Return an immutable fixer given its name if it exists, else return nullptr.

◆ GetFixerByNameAndErrorName()

USDVALIDATION_API const UsdValidationFixer * GetFixerByNameAndErrorName ( const TfToken name) const

Return an immutable fixer given its name and catering to a specific error name if it exists, else return nullptr.

◆ GetFixers()

USDVALIDATION_API const std::vector< const UsdValidationFixer * > GetFixers ( ) const

Return a vector of fixers associated with this Validator.

◆ GetFixersByErrorName()

USDVALIDATION_API const std::vector< const UsdValidationFixer * > GetFixersByErrorName ( ) const

Return a vector of immutable fixers catering to a specific errorName.

◆ GetFixersByKeywords()

USDVALIDATION_API const std::vector< const UsdValidationFixer * > GetFixersByKeywords ( const TfTokenVector keywords) const

Return a vector of immutable fixers catering to any of the given keywords.

Fixers can be associated with keywords, like unit, department, etc. which can be used to filter fixers based on the context in which they are being queried.

◆ GetIdentifier()

USDVALIDATION_API TfToken GetIdentifier ( ) const

An identifier for the error constructed from the validator name this error was generated from and its name.

Since a validator may result in multiple distinct errors, the identifier helps in distinguishing and categorizing the errors. The identifier returned will be in the following form: For a plugin validator: "plugName":"validatorName"."ErrorName" For a non-plugin validator: "validatorName"."ErrorName"

For an error that was generated without a name, the identifier will be same as the validator name which generated the error.

For an error which is created directly and not via UsdValidationValidator::Validate() call, we throw a coding error, as its an improper use of the API.

◆ GetMessage()

const std::string & GetMessage ( ) const
inline

Returns the message associated with this UsdValidationError.

Definition at line 309 of file error.h.

◆ GetMetadata()

const VtValue & GetMetadata ( ) const
inline

Returns the metadata associated with this UsdValidationError.

Validator writers can provide additional metadata when creating a UsdValidationError instance, which can then be retrieved using this method, and may be used by the fixer associated with the validator.

Definition at line 319 of file error.h.

◆ GetName() [1/2]

TfToken GetName ( ) &&
inline

Returns the name token of the UsdValidationError by-value.

Definition at line 272 of file error.h.

◆ GetName() [2/2]

const TfToken & GetName ( ) const &
inline

Returns the name token of the UsdValidationError.

Definition at line 266 of file error.h.

◆ GetSites() [1/2]

UsdValidationErrorSites GetSites ( ) &&
inline

Returns the UsdValidationErrorSite associated with this UsdValidationError by-value.

Definition at line 293 of file error.h.

◆ GetSites() [2/2]

const UsdValidationErrorSites & GetSites ( ) const &
inline

Returns the UsdValidationErrorSite associated with this UsdValidationError.

Definition at line 286 of file error.h.

◆ GetType()

UsdValidationErrorType GetType ( ) const
inline

Returns the UsdValidationErrorType associated with this UsdValidationError.

Definition at line 279 of file error.h.

◆ GetValidator()

const UsdValidationValidator * GetValidator ( ) const
inline

Returns the UsdValidationValidator that reported this error.

This will return nullptr if there is no UsdValidationValidator associated with this error. This will never be nullptr for validation errors returned from calls to UsdValidationValidator::Validate.

Definition at line 303 of file error.h.

◆ HasNoError()

bool HasNoError ( ) const
inline

Returns true if UsdValidationErrorType is UsdValidationErrorType::None, false otherwise.

Definition at line 348 of file error.h.

◆ operator!=()

bool operator!= ( const UsdValidationError other) const
inline

Definition at line 260 of file error.h.

◆ operator==()

bool operator== ( const UsdValidationError other) const
inline

Definition at line 252 of file error.h.

Friends And Related Function Documentation

◆ UsdValidationValidator

friend class UsdValidationValidator
friend

Definition at line 393 of file error.h.


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