Skip to content

Commit

Permalink
ConfError.message: replace with Configured.error
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Jan 28, 2022
1 parent b3d733c commit 73c5798
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ object Newlines {
ConfDecoderEx.from {
case (_, Conf.Str("source")) => Configured.Ok(BeforeOpenParen())
case (_, _: Conf.Bool) =>
ConfError.message("beforeOpenParen can't be bool").notOk
Configured.error("beforeOpenParen can't be bool")
case (_, conf) =>
SourceHints.codec.read(None, conf).map(BeforeOpenParen.apply)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ object Presets {
val newConf = if (filtered.isEmpty) null else Conf.Obj(filtered)
Configured.ok((x, newConf))
case x =>
ConfError.message(s"$me: unsupported preset: $x").notOk
Configured.error(s"$me: unsupported preset: $x")
}
case presetsMatch(_) =>
val section = Option(sectionName).fold("subsection '")(x => s"'$x.")
val err = s"$me: top-level presets removed since v3.0.0; " +
s"use $section$presetKey = $conf' instead"
Some(ConfError.message(err).notOk)
Some(Configured.error(err))
case _ => None
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ object ScalafmtConfig {
}).getOrElse {
val alternatives = activeStyles.keys.mkString(", ")
val err = s"Unknown style $conf. Expected one of: $alternatives"
ConfError.message(err).notOk
Configured.error(err)
}

private def validate(cfg: ScalafmtConfig): Configured[ScalafmtConfig] = {
Expand Down Expand Up @@ -430,10 +430,8 @@ object ScalafmtConfig {
}
// scalafmt: {}
if (allErrors.isEmpty) Configured.ok(cfg)
else {
val msg = allErrors.mkString("can't use: [\n\t", "\n\t", "\n]")
Configured.notOk(ConfError.message(msg))
}
else
Configured.error(allErrors.mkString("can't use: [\n\t", "\n\t", "\n]"))
}

private val baseDecoder = generic.deriveDecoderEx(default).noTypos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object Imports extends RewriteFactory {
val sortAscii = importRules.contains(AsciiSortImports)
if (sortAscii && sortOriginal) {
val err = "Incompatible rewrites: SortImports and AsciiSortImports"
Configured.NotOk(ConfError.message(err))
Configured.error(err)
} else {
val expand =
obj.imports.expand || importRules.contains(ExpandImportSelectors)
Expand Down

0 comments on commit 73c5798

Please sign in to comment.