Skip to content

Commit

Permalink
Merge pull request #1236 from atlanhq/APP-4780
Browse files Browse the repository at this point in the history
Standardize error messages for log parsing
  • Loading branch information
cmgrote authored Jan 20, 2025
2 parents d3d71eb + 69b0f0f commit 061149d
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object ConnectionXformer {
when (fieldName) {
"connection" -> {
ctx.connectionCache.getByIdentity(assetRef)
?: throw NoSuchElementException("Connection $assetRef not found (in $fieldName).")
?: throw NoSuchElementException("Connection not found (in $fieldName): $assetRef")
}
else -> AssetRefXformer.decode(ctx, assetRef, fieldName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object DataDomainXformer {
when (fieldName) {
DataDomain.PARENT_DOMAIN.atlanFieldName, DataProduct.DATA_DOMAIN.atlanFieldName -> {
ctx.dataDomainCache.getByIdentity(assetRef)?.trimToReference()
?: throw NoSuchElementException("Domain $assetRef not found (in $fieldName).")
?: throw NoSuchElementException("Domain not found (in $fieldName): $assetRef")
}
else -> AssetRefXformer.decode(ctx, assetRef, fieldName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object EnumXformer {
val method = enumClass.getMethod("fromValue", String::class.java)
val result: Any? = method.invoke(null, enum)
if (result == null) {
throw IllegalArgumentException("$enumClass (in field $fieldName) does not have any matching value for: $enum")
throw IllegalArgumentException("No matching value found for $enumClass (in field $fieldName): $enum")
} else {
return result as AtlanEnum
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ object GlossaryCategoryXformer {
when (fieldName) {
GlossaryCategory.PARENT_CATEGORY.atlanFieldName -> {
ctx.categoryCache.getByIdentity(assetRef)?.trimToReference()
?: throw NoSuchElementException("Parent category $assetRef not found (in $fieldName).")
?: throw NoSuchElementException("Parent category not found (in $fieldName): $assetRef")
}
GlossaryTerm.CATEGORIES.atlanFieldName -> {
ctx.categoryCache.getByIdentity(assetRef)?.trimToReference()
?: throw NoSuchElementException("Category relationship $assetRef not found (in $fieldName).")
?: throw NoSuchElementException("Category relationship not found (in $fieldName): $assetRef")
}
else -> AssetRefXformer.decode(ctx, assetRef, fieldName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ object GlossaryTermXformer {
"assignedTerms", in TERM_TO_TERM_FIELDS,
->
ctx.termCache.getByIdentity(assetRef)?.trimToReference()
?: throw NoSuchElementException("Term $assetRef not found (in $fieldName).")
?: throw NoSuchElementException("Term not found (in $fieldName): $assetRef")
else -> AssetRefXformer.decode(ctx, assetRef, fieldName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object GlossaryXformer {
when (fieldName) {
GlossaryTerm.ANCHOR.atlanFieldName -> {
ctx.glossaryCache.getByIdentity(assetRef)?.trimToReference()
?: throw NoSuchElementException("Parent glossary $assetRef not found (in $fieldName).")
?: throw NoSuchElementException("Parent glossary not found (in $fieldName): $assetRef")
}
else -> AssetRefXformer.decode(ctx, assetRef, fieldName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object GroupXformer {
// And if found by alias, return the group name (since that's what we require)
return client.groupCache.getNameForId(idFromAlias)
} catch (e: NotFoundException) {
throw NoSuchElementException("Group name / alias $groupRef is not known to Atlan (in $fieldName).", e)
throw NoSuchElementException("Group name / alias is not known to Atlan (in $fieldName): $groupRef", e)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ object ModelAssetXformer {
.semantic(Reference.SaveSemantic.APPEND)
.build()
} else {
throw NoSuchElementException("Model asset $assetRef not found (in $fieldName).")
throw NoSuchElementException("Model asset not found (in $fieldName): $assetRef")
}
}
in MODEL_ASSET_REF_FIELDS -> {
Expand All @@ -102,7 +102,7 @@ object ModelAssetXformer {
.semantic(Reference.SaveSemantic.REPLACE)
.build()
} else {
throw NoSuchElementException("Model asset $assetRef not found (in $fieldName).")
throw NoSuchElementException("Model asset not found (in $fieldName): $assetRef")
}
}
else -> AssetRefXformer.decode(ctx, assetRef, fieldName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object RoleXformer {
// Try to look up the user reference by username
return client.roleCache.getIdForName(roleRef)
} catch (e: NotFoundException) {
throw NoSuchElementException("Role name $roleRef is not known to Atlan (in $fieldName).", e)
throw NoSuchElementException("Role name is not known to Atlan (in $fieldName): $roleRef", e)
}
}
else -> roleRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object UserXformer {
// And if found by email, return the username (since that's what we require)
return client.userCache.getNameForId(idFromEmail)
} catch (e: NotFoundException) {
throw NoSuchElementException("Username / email address $userRef is not known to Atlan (in $fieldName).", e)
throw NoSuchElementException("Username / email address is not known to Atlan (in $fieldName): $userRef", e)
}
}
}
Expand Down

0 comments on commit 061149d

Please sign in to comment.