Skip to content

Commit

Permalink
Register UsdValidationErrorType as TEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
roggiezhang-nv committed Aug 13, 2024
1 parent 59992d2 commit 230712e
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 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,7 @@ 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 230712e

Please sign in to comment.