Skip to content

Commit

Permalink
Register UsdValidationErrorType as TfEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
roggiezhang-nv committed Aug 13, 2024
1 parent 30392d9 commit 102a3e2
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions pxr/usd/usd/validationError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
// https://openusd.org/license.
//

#include "pxr/base/tf/enum.h"
#include "pxr/usd/usd/validationError.h"

PXR_NAMESPACE_OPEN_SCOPE

TF_REGISTRY_FUNCTION(TfEnum)
{
TF_ADD_ENUM_NAME(UsdValidationErrorType::None, "None");
TF_ADD_ENUM_NAME(UsdValidationErrorType::Error, "Error");
TF_ADD_ENUM_NAME(UsdValidationErrorType::Warn, "Warn");
TF_ADD_ENUM_NAME(UsdValidationErrorType::Info, "Info");
}

UsdValidationErrorSite::UsdValidationErrorSite(
const SdfLayerHandle &layer, const SdfPath &objectPath) :
_layer(layer), _objectPath(objectPath)
Expand Down Expand Up @@ -39,24 +48,8 @@ UsdValidationError::UsdValidationError(const UsdValidationErrorType &type,
std::string
UsdValidationError::GetErrorAsString() const
{
std::string errorTypeAsString;
switch(_errorType) {
case UsdValidationErrorType::None:
return _errorMsg;
break;
case UsdValidationErrorType::Error:
errorTypeAsString = "Error";
break;
case UsdValidationErrorType::Warn:
errorTypeAsString = "Warn";
break;
case UsdValidationErrorType::Info:
errorTypeAsString = "Info";
break;
}

const std::string separator = ": ";
return errorTypeAsString + separator + _errorMsg;
return _errorType == UsdValidationErrorType::None ? _errorMsg : TfStringPrintf(
"%s: %s", TfEnum::GetDisplayName(_errorType).c_str(), _errorMsg.c_str());
}

void
Expand Down

0 comments on commit 102a3e2

Please sign in to comment.