Skip to content

Commit

Permalink
ScalafmtDynamicError: include cause
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Sep 23, 2024
1 parent 760dde4 commit 4adeb3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ object ScalafmtConfigLoader extends ScalafmtConfigLoader {
Try(ConfigFactory.parseFile(config.toFile).getString("version")) match {
case Failure(e: ConfigException.IO)
if e.getCause.isInstanceOf[FileNotFoundException] =>
Left(new ConfigDoesNotExist(config))
Left(new ConfigDoesNotExist(config, e))
case Failure(e: ConfigException.Parse) =>
Left(new ConfigParseError(config, e.getMessage))
case Failure(_: ConfigException.Missing) =>
Left(new ConfigMissingVersion(config))
Left(new ConfigParseError(config, e.getMessage, e.getCause))
case Failure(e: ConfigException.Missing) =>
Left(new ConfigMissingVersion(config, e.getCause))
case Failure(e) => Left(new UnknownConfigError(config, e))
case Success(v) => ScalafmtVersion.parse(v)
.toRight(new ConfigInvalidVersion(config, v))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ object ScalafmtDynamicError {
cause: Throwable = null,
) extends ScalafmtDynamicError(msg, cause)

class ConfigDoesNotExist(configPath: Path)
extends ConfigError(configPath, "Missing config")
class ConfigDoesNotExist(configPath: Path, cause: Throwable = null)
extends ConfigError(configPath, "Missing config", cause)

class ConfigMissingVersion(configPath: Path)
extends ConfigError(configPath, "Missing version")
class ConfigMissingVersion(configPath: Path, cause: Throwable = null)
extends ConfigError(configPath, "Missing version", cause)

class ConfigParseError(configPath: Path, why: String, cause: Throwable = null)
extends ConfigError(configPath, s"Invalid config: $why", cause)
Expand Down

0 comments on commit 4adeb3c

Please sign in to comment.