[Error codes] Fill in missing contexts that were lost where reflection based context population was removed [DPP-606] (#13264)

And rename error arguments that haven't been in camel case yet.

changelog_begin
changelog_end
This commit is contained in:
pbatko-da 2022-03-16 15:07:24 +01:00 committed by GitHub
parent 3f0ded9274
commit c6a0275f6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 176 additions and 144 deletions

View File

@ -10,6 +10,7 @@ import scala.jdk.CollectionConverters._
class DamlError(
override val cause: String,
override val throwableO: Option[Throwable] = None,
extraContext: Map[String, Any] = Map(),
)(implicit
override val code: ErrorCode,
override val errorContext: ContextualizedErrorLogger,
@ -18,6 +19,9 @@ class DamlError(
// Automatically log the error on generation
errorContext.logError(this, Map())
override def context: Map[String, String] =
super.context ++ extraContext.view.mapValues(_.toString)
def rpcStatus(): com.google.rpc.status.Status = {
val status0: com.google.rpc.Status = code.asGrpcStatus(this)
val details: Seq[com.google.protobuf.Any] = status0.getDetailsList.asScala.toSeq
@ -37,10 +41,11 @@ class DamlErrorWithDefiniteAnswer(
override val cause: String,
override val throwableO: Option[Throwable] = None,
val definiteAnswer: Boolean = false,
extraContext: Map[String, Any] = Map(),
)(implicit
override val code: ErrorCode,
loggingContext: ContextualizedErrorLogger,
) extends DamlError(cause = cause, throwableO = throwableO) {
) extends DamlError(cause = cause, throwableO = throwableO, extraContext = extraContext) {
final override def definiteAnswerO: Option[Boolean] = Some(definiteAnswer)

View File

@ -36,9 +36,9 @@ object LedgerApiErrors extends LedgerApiErrorGroup {
ErrorCategory.InternalUnsupportedOperation,
) {
case class Reject(_message: String)(implicit errorLogger: ContextualizedErrorLogger)
case class Reject(message: String)(implicit errorLogger: ContextualizedErrorLogger)
extends DamlErrorWithDefiniteAnswer(
cause = s"The request exercised an unsupported operation: ${_message}"
cause = s"The request exercised an unsupported operation: ${message}"
)
}
@ -60,10 +60,10 @@ object LedgerApiErrors extends LedgerApiErrorGroup {
override def logLevel: Level = Level.WARN
case class Rejection(reason: String)(implicit errorLogger: ContextualizedErrorLogger)
extends DamlErrorWithDefiniteAnswer(cause = s"The participant is overloaded: $reason") {
override def context: Map[String, String] =
super.context ++ Map("reason" -> reason)
}
extends DamlErrorWithDefiniteAnswer(
cause = s"The participant is overloaded: $reason",
extraContext = Map("reason" -> reason),
)
}
@Explanation(
@ -77,11 +77,11 @@ object LedgerApiErrors extends LedgerApiErrorGroup {
id = "REQUEST_TIME_OUT",
ErrorCategory.DeadlineExceededRequestStateUnknown,
) {
case class Reject(_message: String, _definiteAnswer: Boolean)(implicit
case class Reject(message: String, override val definiteAnswer: Boolean)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = _message,
definiteAnswer = _definiteAnswer,
cause = message,
definiteAnswer = definiteAnswer,
)
}
@ -94,14 +94,12 @@ object LedgerApiErrors extends LedgerApiErrorGroup {
id = "SERVICE_NOT_RUNNING",
ErrorCategory.TransientServerFailure,
) {
case class Reject(_serviceName: String)(implicit
case class Reject(serviceName: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = s"${_serviceName} has been shut down."
) {
override def context: Map[String, String] =
super.context ++ Map("service_name" -> _serviceName)
}
cause = s"${serviceName} has been shut down.",
extraContext = Map("service_name" -> serviceName),
)
}
@Explanation("This rejection is given when the participant server is shutting down.")
@ -138,10 +136,10 @@ object LedgerApiErrors extends LedgerApiErrorGroup {
override val throwableO: Option[Throwable] = None,
)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(cause = message) {
override def context: Map[String, String] =
super.context ++ Map("throwableO" -> throwableO.toString)
}
) extends DamlErrorWithDefiniteAnswer(
cause = message,
extraContext = Map("throwableO" -> throwableO.toString),
)
case class PackageSelfConsistency(
err: LfError.Package.SelfConsistency
@ -178,7 +176,8 @@ object LedgerApiErrors extends LedgerApiErrorGroup {
)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = s"Daml-Engine interpretation failed with internal error: ${where} / ${message}"
cause = s"Daml-Engine interpretation failed with internal error: ${where} / ${message}",
extraContext = Map("detailMessage" -> detailMessage),
)
case class VersionService(message: String)(implicit

View File

@ -28,7 +28,8 @@ object PackageServiceError extends LedgerApiErrors.PackageServiceErrorGroup {
final case class Error(reason: String)(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = "Dar file name is invalid"
cause = "Dar file name is invalid",
extraContext = Map("reason" -> reason),
)
}
@ -41,6 +42,10 @@ object PackageServiceError extends LedgerApiErrors.PackageServiceErrorGroup {
) extends DamlError(
cause = "Dar file is corrupt",
throwableO = Some(throwable),
extraContext = Map(
"entries" -> entries,
"throwable" -> throwable,
),
)
}
@Explanation("""This error indicates that the supplied zipped dar file was invalid.""")
@ -50,7 +55,11 @@ object PackageServiceError extends LedgerApiErrors.PackageServiceErrorGroup {
final case class Error(name: String, entries: Seq[String])(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = "Dar zip file is corrupt"
cause = "Dar zip file is corrupt",
extraContext = Map(
"name" -> name,
"entries" -> entries,
),
)
}
@ -66,7 +75,8 @@ object PackageServiceError extends LedgerApiErrors.PackageServiceErrorGroup {
final case class Error(entries: Seq[String])(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = "Unsupported legacy Dar zip file"
cause = "Unsupported legacy Dar zip file",
extraContext = Map("entries" -> entries),
)
}
@ -77,7 +87,8 @@ object PackageServiceError extends LedgerApiErrors.PackageServiceErrorGroup {
final case class Error(msg: String)(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = "Dar zip file seems to be a zip bomb."
cause = "Dar zip file seems to be a zip bomb.",
extraContext = Map("msg" -> msg),
)
}
@ -90,7 +101,8 @@ object PackageServiceError extends LedgerApiErrors.PackageServiceErrorGroup {
final case class Error(reason: String)(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = "Failed to parse the dar file content."
cause = "Failed to parse the dar file content.",
extraContext = Map(reason -> reason),
)
}
@ -106,27 +118,31 @@ object PackageServiceError extends LedgerApiErrors.PackageServiceErrorGroup {
final case class Validation(nameOfFunc: String, msg: String, detailMsg: String = "")(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = "Internal package validation error."
cause = "Internal package validation error.",
extraContext = Map(
"nameOfFunc" -> nameOfFunc,
"msg" -> msg,
"detailMsg" -> detailMsg,
),
)
final case class Error(missing: Set[PackageId])(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = "Failed to resolve package ids locally."
cause = "Failed to resolve package ids locally.",
extraContext = Map("missing" -> missing),
)
final case class Generic(reason: String)(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = "Generic error (please check the reason string)."
) {
override def context: Map[String, String] = super.context ++ Map(
"reason" -> reason
)
}
cause = "Generic error (please check the reason string).",
extraContext = Map("reason" -> reason),
)
final case class Unhandled(throwable: Throwable)(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = "Failed with an unknown error cause",
throwableO = Some(throwable),
extraContext = Map("throwable" -> throwable),
)
}
@ -183,7 +199,8 @@ object PackageServiceError extends LedgerApiErrors.PackageServiceErrorGroup {
final case class Error(validationError: validation.ValidationError)(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = "Package validation failed."
cause = "Package validation failed.",
extraContext = Map("validationError" -> validationError),
)
}
@ -195,7 +212,12 @@ object PackageServiceError extends LedgerApiErrors.PackageServiceErrorGroup {
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = LedgerApiErrors.CommandExecution.Package.AllowedLanguageVersions
.buildCause(packageId, languageVersion, allowedLanguageVersions)
.buildCause(packageId, languageVersion, allowedLanguageVersions),
extraContext = Map(
"packageId" -> packageId,
"languageVersion" -> languageVersion.toString,
"allowedLanguageVersions" -> allowedLanguageVersions.toString,
),
)(
LedgerApiErrors.CommandExecution.Package.AllowedLanguageVersions,
loggingContext,
@ -217,7 +239,11 @@ object PackageServiceError extends LedgerApiErrors.PackageServiceErrorGroup {
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause =
"The set of packages in the dar is not self-consistent and is missing dependencies"
"The set of packages in the dar is not self-consistent and is missing dependencies",
extraContext = Map(
"packageIds" -> packageIds,
"missingDependencies" -> missingDependencies,
),
)
}
}

View File

@ -38,11 +38,11 @@ object CommandExecution extends LedgerApiErrors.CommandExecutionErrorGroup {
ErrorCategory.ContentionOnSharedResources,
) {
case class Reject(_reason: String)(implicit
case class Reject(reason: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause =
s"The participant failed to determine the max ledger time for this command: ${_reason}"
s"The participant failed to determine the max ledger time for this command: ${reason}"
)
}
@ -165,14 +165,14 @@ object CommandExecution extends LedgerApiErrors.CommandExecutionErrorGroup {
case class Reject(
override val cause: String,
_err: LfInterpretationError.ContractNotActive,
err: LfInterpretationError.ContractNotActive,
)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = cause
) {
override def resources: Seq[(ErrorResource, String)] = Seq(
(ErrorResource.ContractId, _err.coid.coid)
(ErrorResource.ContractId, err.coid.coid)
)
}
@ -194,14 +194,14 @@ object CommandExecution extends LedgerApiErrors.CommandExecutionErrorGroup {
case class Reject(
override val cause: String,
_key: GlobalKey,
key: GlobalKey,
)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = cause
) {
override def resources: Seq[(ErrorResource, String)] = Seq(
(ErrorResource.ContractKey, _key.toString())
(ErrorResource.ContractKey, key.toString())
)
}
}

View File

@ -37,19 +37,19 @@ object ConsistencyErrors extends LedgerApiErrors.ConsistencyErrors {
) {
case class Reject(
_definiteAnswer: Boolean = false,
_existingCommandSubmissionId: Option[String],
_changeId: Option[ChangeId] = None,
override val definiteAnswer: Boolean = false,
existingCommandSubmissionId: Option[String],
changeId: Option[ChangeId] = None,
)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = "A command with the given command id has already been successfully processed",
definiteAnswer = _definiteAnswer,
definiteAnswer = definiteAnswer,
) {
override def context: Map[String, String] =
super.context ++ _existingCommandSubmissionId
super.context ++ existingCommandSubmissionId
.map("existing_submission_id" -> _)
.toList ++ _changeId
.toList ++ changeId
.map(changeId => Seq("changeId" -> changeId.toString))
.getOrElse(Seq.empty)
}
@ -105,26 +105,26 @@ object ConsistencyErrors extends LedgerApiErrors.ConsistencyErrors {
ErrorCategory.InvalidGivenCurrentSystemStateResourceMissing,
) {
case class MultipleContractsNotFound(_notFoundContractIds: Set[String])(implicit
case class MultipleContractsNotFound(notFoundContractIds: Set[String])(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = s"Unknown contracts: ${_notFoundContractIds.mkString("[", ", ", "]")}"
cause = s"Unknown contracts: ${notFoundContractIds.mkString("[", ", ", "]")}"
) {
override def resources: Seq[(ErrorResource, String)] = Seq(
(ErrorResource.ContractId, _notFoundContractIds.mkString("[", ", ", "]"))
(ErrorResource.ContractId, notFoundContractIds.mkString("[", ", ", "]"))
)
}
case class Reject(
override val cause: String,
_cid: Value.ContractId,
cid: Value.ContractId,
)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = cause
) {
override def resources: Seq[(ErrorResource, String)] = Seq(
(ErrorResource.ContractId, _cid.coid)
(ErrorResource.ContractId, cid.coid)
)
}
@ -158,7 +158,7 @@ object ConsistencyErrors extends LedgerApiErrors.ConsistencyErrors {
case class RejectWithContractKeyArg(
override val cause: String,
_key: GlobalKey,
key: GlobalKey,
)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
@ -167,7 +167,7 @@ object ConsistencyErrors extends LedgerApiErrors.ConsistencyErrors {
override def resources: Seq[(ErrorResource, String)] = Seq(
// TODO error codes: Reconsider the transport format for the contract key.
// If the key is big, it can force chunking other resources.
(ErrorResource.ContractKey, _key.toString())
(ErrorResource.ContractKey, key.toString())
)
}
@ -189,15 +189,15 @@ object ConsistencyErrors extends LedgerApiErrors.ConsistencyErrors {
case class RejectEnriched(
override val cause: String,
ledger_time: Instant,
ledger_time_lower_bound: Instant,
ledger_time_upper_bound: Instant,
ledgerTime: Instant,
ledgerTimeLowerBound: Instant,
ledgerTimeUpperBound: Instant,
)(implicit loggingContext: ContextualizedErrorLogger)
extends DamlErrorWithDefiniteAnswer(cause = cause) {
override def context: Map[String, String] = super.context ++ Map(
"ledger_time" -> ledger_time.toString,
"ledger_time_lower_bound" -> ledger_time_lower_bound.toString,
"ledger_time_upper_bound" -> ledger_time_upper_bound.toString,
"ledger_time" -> ledgerTime.toString,
"ledger_time_lower_bound" -> ledgerTimeLowerBound.toString,
"ledger_time_upper_bound" -> ledgerTimeUpperBound.toString,
)
}

View File

@ -33,14 +33,14 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
id = "PACKAGE_NOT_FOUND",
ErrorCategory.InvalidGivenCurrentSystemStateResourceMissing,
) {
case class Reject(_packageId: String)(implicit
case class Reject(packageId: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = "Could not find package."
) {
override def resources: Seq[(ErrorResource, String)] = {
super.resources :+ ((ErrorResource.DalfPackage, _packageId))
super.resources :+ ((ErrorResource.DalfPackage, packageId))
}
}
@ -66,11 +66,11 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
ErrorCategory.InvalidGivenCurrentSystemStateResourceMissing,
) {
case class Reject(_transactionId: String)(implicit
case class Reject(transactionId: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(cause = "Transaction not found, or not visible.") {
override def resources: Seq[(ErrorResource, String)] = Seq(
(ErrorResource.TransactionId, _transactionId)
(ErrorResource.TransactionId, transactionId)
)
}
}
@ -91,10 +91,10 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
cause = "The ledger configuration could not be retrieved."
)
case class RejectWithMessage(_message: String)(implicit
case class RejectWithMessage(message: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = s"The ledger configuration could not be retrieved: ${_message}."
cause = s"The ledger configuration could not be retrieved: ${message}."
)
}
}
@ -106,13 +106,12 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
id = "PARTICIPANT_PRUNED_DATA_ACCESSED",
ErrorCategory.InvalidGivenCurrentSystemStateOther,
) {
case class Reject(override val cause: String, _earliestOffset: String)(implicit
case class Reject(override val cause: String, earliestOffset: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(cause = cause) {
override def context: Map[String, String] =
super.context + (EarliestOffsetMetadataKey -> _earliestOffset)
}
) extends DamlErrorWithDefiniteAnswer(
cause = cause,
extraContext = Map(EarliestOffsetMetadataKey -> earliestOffset),
)
}
@Explanation(
@ -124,10 +123,10 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
id = "OFFSET_AFTER_LEDGER_END",
ErrorCategory.InvalidGivenCurrentSystemStateSeekAfterEnd,
) {
case class Reject(_offsetType: String, _requestedOffset: String, _ledgerEnd: String)(implicit
case class Reject(offsetType: String, requestedOffset: String, ledgerEnd: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = s"${_offsetType} offset (${_requestedOffset}) is after ledger end (${_ledgerEnd})"
cause = s"${offsetType} offset (${requestedOffset}) is after ledger end (${ledgerEnd})"
)
}
@ -140,9 +139,9 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
id = "OFFSET_OUT_OF_RANGE",
ErrorCategory.InvalidGivenCurrentSystemStateOther,
) {
case class Reject(_message: String)(implicit
case class Reject(message: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(cause = _message)
) extends DamlErrorWithDefiniteAnswer(cause = message)
}
@Explanation(
@ -155,11 +154,11 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
id = "LEDGER_ID_MISMATCH",
ErrorCategory.InvalidGivenCurrentSystemStateResourceMissing,
) {
case class Reject(_expectedLedgerId: String, _receivedLegerId: String)(implicit
case class Reject(expectedLedgerId: String, receivedLegerId: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause =
s"Ledger ID '${_receivedLegerId}' not found. Actual Ledger ID is '${_expectedLedgerId}'.",
s"Ledger ID '${receivedLegerId}' not found. Actual Ledger ID is '${expectedLedgerId}'.",
definiteAnswer = true,
)
}
@ -170,14 +169,12 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
@Resolution("Inspect the reason given and correct your application.")
object MissingField
extends ErrorCode(id = "MISSING_FIELD", ErrorCategory.InvalidIndependentOfSystemState) {
case class Reject(_missingField: String)(implicit
case class Reject(missingField: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = s"The submitted command is missing a mandatory field: ${_missingField}"
) {
override def context: Map[String, String] =
super.context ++ Map("field_name" -> _missingField)
}
cause = s"The submitted command is missing a mandatory field: ${missingField}",
extraContext = Map("field_name" -> missingField),
)
}
@Explanation(
@ -186,10 +183,10 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
@Resolution("Inspect the reason given and correct your application.")
object InvalidArgument
extends ErrorCode(id = "INVALID_ARGUMENT", ErrorCategory.InvalidIndependentOfSystemState) {
case class Reject(_reason: String)(implicit
case class Reject(reason: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = s"The submitted command has invalid arguments: ${_reason}"
cause = s"The submitted command has invalid arguments: ${reason}"
)
}
@ -199,11 +196,11 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
@Resolution("Inspect the reason given and correct your application.")
object InvalidField
extends ErrorCode(id = "INVALID_FIELD", ErrorCategory.InvalidIndependentOfSystemState) {
case class Reject(_fieldName: String, _message: String)(implicit
case class Reject(fieldName: String, message: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause =
s"The submitted command has a field with invalid value: Invalid field ${_fieldName}: ${_message}"
s"The submitted command has a field with invalid value: Invalid field ${fieldName}: ${message}"
)
}
@ -220,15 +217,15 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
) {
val ValidMaxDeduplicationFieldKey = "longest_duration"
case class Reject(
_reason: String,
_maxDeduplicationDuration: Option[Duration],
reason: String,
maxDeduplicationDuration: Option[Duration],
)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = s"The submitted command had an invalid deduplication period: ${_reason}"
cause = s"The submitted command had an invalid deduplication period: ${reason}"
) {
override def context: Map[String, String] = {
super.context ++ _maxDeduplicationDuration
super.context ++ maxDeduplicationDuration
.map(ValidMaxDeduplicationFieldKey -> _.toString)
.toList
}
@ -243,14 +240,13 @@ object RequestValidation extends LedgerApiErrors.RequestValidation {
ErrorCategory.InvalidIndependentOfSystemState,
) {
case class Error(
_fieldName: String,
_offsetValue: String,
_message: String,
fieldName: String,
offsetValue: String,
message: String,
)(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause =
s"Offset in ${_fieldName} not specified in hexadecimal: ${_offsetValue}: ${_message}"
cause = s"Offset in ${fieldName} not specified in hexadecimal: ${offsetValue}: ${message}"
)
}
}

View File

@ -24,10 +24,10 @@ object UserManagementServiceErrors extends AdminServices.UserManagementServiceEr
id = "USER_NOT_FOUND",
ErrorCategory.InvalidGivenCurrentSystemStateResourceMissing,
) {
case class Reject(_operation: String, userId: String)(implicit
case class Reject(operation: String, userId: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = s"${_operation} failed for unknown user \"${userId}\""
cause = s"${operation} failed for unknown user \"${userId}\""
) {
override def resources: Seq[(ErrorResource, String)] = Seq(
ErrorResource.User -> userId
@ -43,10 +43,10 @@ object UserManagementServiceErrors extends AdminServices.UserManagementServiceEr
id = "USER_ALREADY_EXISTS",
ErrorCategory.InvalidGivenCurrentSystemStateResourceExists,
) {
case class Reject(_operation: String, userId: String)(implicit
case class Reject(operation: String, userId: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = s"${_operation} failed, as user \"${userId}\" already exists"
cause = s"${operation} failed, as user \"${userId}\" already exists"
) {
override def resources: Seq[(ErrorResource, String)] = Seq(
ErrorResource.User -> userId
@ -67,10 +67,10 @@ object UserManagementServiceErrors extends AdminServices.UserManagementServiceEr
id = "TOO_MANY_USER_RIGHTS",
ErrorCategory.InvalidGivenCurrentSystemStateOther,
) {
case class Reject(_operation: String, userId: String)(implicit
case class Reject(operation: String, userId: String)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(
cause = s"${_operation} failed, as user \"${userId}\" would have too many rights."
cause = s"${operation} failed, as user \"${userId}\" would have too many rights."
) {
override def resources: Seq[(ErrorResource, String)] = Seq(
ErrorResource.User -> userId

View File

@ -30,13 +30,13 @@ object WriteServiceRejections extends LedgerApiErrors.WriteServiceRejections {
ErrorCategory.InvalidGivenCurrentSystemStateResourceMissing, // It may become known at a later time
) {
case class Reject(
submitter_party: String
submitterParty: String
)(implicit loggingContext: ContextualizedErrorLogger)
extends DamlErrorWithDefiniteAnswer(
cause = s"Party not known on ledger: Submitting party '$submitter_party' not known"
cause = s"Party not known on ledger: Submitting party '$submitterParty' not known"
) {
override def resources: Seq[(ErrorResource, String)] = Seq(
ErrorResource.Party -> submitter_party
ErrorResource.Party -> submitterParty
)
}
}
@ -51,12 +51,12 @@ object WriteServiceRejections extends LedgerApiErrors.WriteServiceRejections {
id = "PARTY_NOT_KNOWN_ON_LEDGER",
ErrorCategory.InvalidGivenCurrentSystemStateResourceMissing,
) {
case class Reject(_parties: Set[String])(implicit
case class Reject(parties: Set[String])(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(cause = s"Parties not known on ledger: ${_parties
) extends DamlErrorWithDefiniteAnswer(cause = s"Parties not known on ledger: ${parties
.mkString("[", ",", "]")}") {
override def resources: Seq[(ErrorResource, String)] =
_parties.map((ErrorResource.Party, _)).toSeq
parties.map((ErrorResource.Party, _)).toSeq
}
@deprecated
@ -110,7 +110,13 @@ object WriteServiceRejections extends LedgerApiErrors.WriteServiceRejections {
submitter: String,
participantId: String,
)(implicit loggingContext: ContextualizedErrorLogger)
extends DamlErrorWithDefiniteAnswer(cause = s"Inconsistent: $details")
extends DamlErrorWithDefiniteAnswer(
cause = s"Inconsistent: $details",
extraContext = Map(
"submitter" -> submitter,
"participantId" -> participantId,
),
)
case class Reject(
details: String
@ -131,11 +137,11 @@ object WriteServiceRejections extends LedgerApiErrors.WriteServiceRejections {
id = "INTERNALLY_INCONSISTENT_KEYS",
ErrorCategory.SystemInternalAssumptionViolated, // Should have been caught by the participant
) {
case class Reject(override val cause: String, _keyO: Option[GlobalKey] = None)(implicit
case class Reject(override val cause: String, keyO: Option[GlobalKey] = None)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(cause = cause) {
override def resources: Seq[(ErrorResource, String)] =
super.resources ++ _keyO.map(key => ErrorResource.ContractKey -> key.toString).toList
super.resources ++ keyO.map(key => ErrorResource.ContractKey -> key.toString).toList
}
}
@ -149,11 +155,11 @@ object WriteServiceRejections extends LedgerApiErrors.WriteServiceRejections {
id = "INTERNALLY_DUPLICATE_KEYS",
ErrorCategory.SystemInternalAssumptionViolated, // Should have been caught by the participant
) {
case class Reject(override val cause: String, _keyO: Option[GlobalKey] = None)(implicit
case class Reject(override val cause: String, keyO: Option[GlobalKey] = None)(implicit
loggingContext: ContextualizedErrorLogger
) extends DamlErrorWithDefiniteAnswer(cause = cause) {
override def resources: Seq[(ErrorResource, String)] =
super.resources ++ _keyO.map(key => ErrorResource.ContractKey -> key.toString).toList
super.resources ++ keyO.map(key => ErrorResource.ContractKey -> key.toString).toList
}
}
}

View File

@ -29,7 +29,7 @@ object DummmyServer {
Some("full-correlation-id-123456790"),
)
case class Error(_message: String) extends DamlError(cause = _message) {
case class Error(message: String) extends DamlError(cause = message) {
override def resources: Seq[(ErrorResource, String)] = Seq(
ErrorResource.ContractId -> "someContractId"

View File

@ -23,7 +23,7 @@ class ErrorDetailsSpec extends AnyFlatSpec with Matchers {
val securitySensitive =
LedgerApiErrors.AuthorizationChecks.Unauthenticated.MissingJwtToken()(errorLogger).asGrpcError
val notSecuritySensitive = LedgerApiErrors.Admin.UserManagement.UserNotFound
.Reject(_operation = "operation123", userId = "userId123")(errorLogger)
.Reject(operation = "operation123", userId = "userId123")(errorLogger)
.asGrpcError
ErrorDetails.matches(

View File

@ -120,7 +120,7 @@ object CompletionResponse {
LedgerApiErrors.RequestTimeOut
.Reject(
"Timed out while awaiting for a completion corresponding to a command submission.",
_definiteAnswer = false,
definiteAnswer = false,
)
.asGrpcStatus
case CompletionResponse.NoStatusInResponse(_, _) =>

View File

@ -254,9 +254,9 @@ final class CommandsValidator(ledgerId: LedgerId) {
Left(
LedgerApiErrors.RequestValidation.NonHexOffset
.Error(
_fieldName = "deduplication_period",
_offsetValue = offset,
_message =
fieldName = "deduplication_period",
offsetValue = offset,
message =
s"the deduplication offset has to be a hexadecimal string and not $offset",
)
.asGrpcError

View File

@ -28,7 +28,7 @@ object ValidationErrors {
message: String,
)(implicit contextualizedErrorLogger: ContextualizedErrorLogger): StatusRuntimeException =
LedgerApiErrors.RequestValidation.InvalidField
.Reject(_fieldName = fieldName, _message = message)
.Reject(fieldName = fieldName, message = message)
.asGrpcError
}

View File

@ -197,7 +197,7 @@ class ErrorFactoriesSpec
LedgerApiErrors.RequestTimeOut
.Reject(
"Timed out while awaiting for a completion corresponding to a command submission.",
_definiteAnswer = false,
definiteAnswer = false,
)(
contextualizedErrorLogger
)
@ -330,7 +330,7 @@ class ErrorFactoriesSpec
s"DUPLICATE_COMMAND(10,$truncatedCorrelationId): A command with the given command id has already been successfully processed"
assertError(
LedgerApiErrors.ConsistencyErrors.DuplicateCommand
.Reject(_existingCommandSubmissionId = None)
.Reject(existingCommandSubmissionId = None)
)(
code = Code.ALREADY_EXISTS,
message = msg,
@ -366,7 +366,7 @@ class ErrorFactoriesSpec
val msg = s"REQUEST_TIME_OUT(3,$truncatedCorrelationId): message123"
assertError(
LedgerApiErrors.RequestTimeOut
.Reject("message123", _definiteAnswer = false)
.Reject("message123", definiteAnswer = false)
)(
code = Code.DEADLINE_EXCEEDED,
message = msg,
@ -392,9 +392,9 @@ class ErrorFactoriesSpec
assertError(
LedgerApiErrors.RequestValidation.NonHexOffset
.Error(
_fieldName = "fieldName123",
_offsetValue = "offsetValue123",
_message = "message123",
fieldName = "fieldName123",
offsetValue = "offsetValue123",
message = "message123",
)
.asGrpcError
)(
@ -525,8 +525,8 @@ class ErrorFactoriesSpec
assertError(
LedgerApiErrors.RequestValidation.InvalidDeduplicationPeriodField
.Reject(
_reason = errorDetailMessage,
_maxDeduplicationDuration = Some(maxDeduplicationDuration),
reason = errorDetailMessage,
maxDeduplicationDuration = Some(maxDeduplicationDuration),
)
.asGrpcError
)(

View File

@ -52,7 +52,7 @@ private[apiserver] final class ApiPackageService private (
case None =>
Future.failed[GetPackageResponse](
LedgerApiErrors.RequestValidation.NotFound.Package
.Reject(_packageId = packageId)(
.Reject(packageId = packageId)(
createContextualizedErrorLogger
)
.asGrpcError

View File

@ -151,9 +151,9 @@ final class ApiParticipantPruningService private (
.map(t =>
LedgerApiErrors.RequestValidation.NonHexOffset
.Error(
_fieldName = "prune_up_to",
_offsetValue = pruneUpToString,
_message =
fieldName = "prune_up_to",
offsetValue = pruneUpToString,
message =
s"prune_up_to needs to be a hexadecimal string and not $pruneUpToString: ${t.getMessage}",
)
.asGrpcError

View File

@ -59,7 +59,7 @@ class SynchronousResponse[Input, Entry, AcceptedEntry](
case _: TimeoutException =>
Future.failed(
LedgerApiErrors.RequestTimeOut
.Reject("Request timed out", _definiteAnswer = false)(
.Reject("Request timed out", definiteAnswer = false)(
new DamlContextualizedErrorLogger(logger, loggingContext, Some(submissionId))
)
.asGrpcError

View File

@ -61,7 +61,7 @@ case class QueryNonPrunedImpl(
throw LedgerApiErrors.RequestValidation.ParticipantPrunedDataAccessed
.Reject(
cause = error(pruningOffsetUpToInclusive),
_earliestOffset = pruningOffsetUpToInclusive.toHexString,
earliestOffset = pruningOffsetUpToInclusive.toHexString,
)(
new DamlContextualizedErrorLogger(logger, loggingContext, None)
)

View File

@ -260,10 +260,10 @@ object ErrorInterceptorSpec {
ErrorCategory.InvalidGivenCurrentSystemStateResourceMissing,
)(ErrorClass.root()) {
case class Error(_msg: String)(implicit
case class Error(msg: String)(implicit
val loggingContext: ContextualizedErrorLogger
) extends DamlError(
cause = s"Foo is missing: ${_msg}"
cause = s"Foo is missing: ${msg}"
)
}

View File

@ -211,17 +211,17 @@ private[kvutils] object TransactionRejections {
LedgerApiErrors.ConsistencyErrors.InvalidLedgerTime
.RejectEnriched(
cause = details,
ledger_time = Instant
ledgerTime = Instant
.ofEpochSecond(
ledgerTime.getSeconds,
ledgerTime.getNanos.toLong,
),
ledger_time_lower_bound = Instant
ledgerTimeLowerBound = Instant
.ofEpochSecond(
ledgerTimeLowerBound.getSeconds,
ledgerTimeLowerBound.getNanos.toLong,
),
ledger_time_upper_bound = Instant
ledgerTimeUpperBound = Instant
.ofEpochSecond(
ledgerTimeUpperBound.getSeconds,
ledgerTimeUpperBound.getNanos.toLong,

View File

@ -35,7 +35,7 @@ private[sandbox] object Rejection {
) extends Rejection {
override def toStatus: Status =
LedgerApiErrors.ConsistencyErrors.DuplicateContractKey
.RejectWithContractKeyArg(cause = "DuplicateKey: contract key is not unique", _key = key)
.RejectWithContractKeyArg(cause = "DuplicateKey: contract key is not unique", key = key)
.rpcStatus()
}
@ -142,7 +142,7 @@ private[sandbox] object Rejection {
) extends Rejection {
override def toStatus: Status =
LedgerApiErrors.ConsistencyErrors.DuplicateCommand
.Reject(_definiteAnswer = false, None, Some(changeId))
.Reject(definiteAnswer = false, None, Some(changeId))
.rpcStatus()
}