Skip to content

Commit

Permalink
alter approach to make mima happier
Browse files Browse the repository at this point in the history
  • Loading branch information
asr2003 authored Nov 11, 2024
1 parent 9824fdf commit b050aba
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions zio-http/shared/src/main/scala/zio/http/ErrorResponseConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,39 @@ final case class ErrorResponseConfig(
withStackTrace: Boolean = false,
maxStackTraceDepth: Int = 10,
errorFormat: ErrorResponseConfig.ErrorFormat = ErrorResponseConfig.ErrorFormat.Html,
logCodecErrors: Boolean = false,
)
logCodecErrors: Boolean = false
) {

/**
* Backward-compatible copy method for compatibility with older code.
*
* Omits the new `logCodecErrors` parameter, which defaults to `false` in
* older usage scenarios.
*/
def copy(
withErrorBody: Boolean = this.withErrorBody,
withStackTrace: Boolean = this.withStackTrace,
maxStackTraceDepth: Int = this.maxStackTraceDepth,
errorFormat: ErrorResponseConfig.ErrorFormat = this.errorFormat
): ErrorResponseConfig =
new ErrorResponseConfig(withErrorBody, withStackTrace, maxStackTraceDepth, errorFormat, logCodecErrors)

/**
* Full copy method including all parameters.
*/
def copyWithLog(
withErrorBody: Boolean = this.withErrorBody,
withStackTrace: Boolean = this.withStackTrace,
maxStackTraceDepth: Int = this.maxStackTraceDepth,
errorFormat: ErrorResponseConfig.ErrorFormat = this.errorFormat,
logCodecErrors: Boolean = this.logCodecErrors
): ErrorResponseConfig =
new ErrorResponseConfig(withErrorBody, withStackTrace, maxStackTraceDepth, errorFormat, logCodecErrors)
}

object ErrorResponseConfig {
sealed trait ErrorFormat { val mediaType: MediaType }
object ErrorFormat {
object ErrorFormat {
case object Text extends ErrorFormat { val mediaType: MediaType = MediaType.text.`plain` }
case object Html extends ErrorFormat { val mediaType: MediaType = MediaType.text.html }
case object Json extends ErrorFormat { val mediaType: MediaType = MediaType.application.json }
Expand All @@ -38,7 +65,7 @@ object ErrorResponseConfig {
withErrorBody: Boolean,
withStackTrace: Boolean,
maxStackTraceDepth: Int,
errorFormat: ErrorFormat,
errorFormat: ErrorFormat
): ErrorResponseConfig =
new ErrorResponseConfig(withErrorBody, withStackTrace, maxStackTraceDepth, errorFormat, logCodecErrors = false)

Expand Down

0 comments on commit b050aba

Please sign in to comment.