Skip to content

Commit

Permalink
Turn anon exception in configuration format exception
Browse files Browse the repository at this point in the history
So that output is prettier.
  • Loading branch information
jvican committed Mar 28, 2018
1 parent 1ac59f2 commit 1de9a95
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions frontend/src/main/scala/bloop/Project.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ object Project {
fromProperties(properties, config, logger)
}

private class MissingFieldError(fieldName: String, config: AbsolutePath)
extends Exception(
s"""The field '$fieldName' is missing in '${config.syntax}'.
|Please export your project again from your build tool (e.g. `bloopInstall`).
|Check the installation page for further information: https://scalacenter.github.io/bloop/docs/installation""".stripMargin
) with NoStackTrace

def fromProperties(properties: Properties, config: AbsolutePath, logger: Logger): Project = {
def toPaths(line: String) = line.split(",").map(toPath)
def toPath(line: String) = AbsolutePath(NioPaths.get(line))
Expand All @@ -108,13 +115,8 @@ object Project {
val classpathOptions = {
val opts = properties.getProperty("classpathOptions")
// Protecting our users from breaking changes in the configuration file format.
if (opts == null) {
throw new Exception(
"""The field for classpath options doesn't exist.
|Please export your project again from your build tool (e.g. `bloopInstall`).
|Check the installation page for further information: https://scalacenter.github.io/bloop/docs/installation
""".stripMargin) with NoStackTrace
} else {
if (opts == null) throw new MissingFieldError("classpathOptions", config)
else {
val values = opts.split(",")
val Array(bootLibrary, compiler, extra, autoBoot, filterLibrary) =
values.map(java.lang.Boolean.parseBoolean)
Expand Down

0 comments on commit 1de9a95

Please sign in to comment.