Skip to content

Commit

Permalink
preserve internal error
Browse files Browse the repository at this point in the history
  • Loading branch information
tpolecat committed Aug 16, 2024
1 parent 0ad79d0 commit adc3c07
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions modules/core/src/main/scala/result.scala
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ sealed trait Result[+T] {
case _ => false
}

def isFailure: Boolean =
this match {
case Result.Failure(_) => true
case _ => false
}

def hasProblems: Boolean =
this match {
case Result.Warning(_, _) => true
Expand Down
8 changes: 7 additions & 1 deletion modules/sql/shared/src/main/scala/SqlMapping.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3557,7 +3557,13 @@ trait SqlMappingLike[F[_]] extends CirceMappingLike[F] with SqlModule[F] { self
Result.failure(s"No field '$fieldName' for type ${context.tpe}")
}

localField orElse mkCursorForField(this, fieldName, resultName)
// Fall back to the general implementation if it's a logic failure,
// but retain success and internal errors.
if (localField.isFailure)
mkCursorForField(this, fieldName, resultName)
else
localField

}
}

Expand Down

0 comments on commit adc3c07

Please sign in to comment.