diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-19 19:52:56 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-19 21:57:55 -0400 |
commit | 5388bb116834196e1b0a9bd9f2622f36e842b3be (patch) | |
tree | 468ba146c0417cca2b12d1924bcf84cabffc3646 /stage1 | |
parent | bb409cc1701b83a3335902789cb4309b64d4e26e (diff) | |
download | cbt-5388bb116834196e1b0a9bd9f2622f36e842b3be.tar.gz cbt-5388bb116834196e1b0a9bd9f2622f36e842b3be.tar.bz2 cbt-5388bb116834196e1b0a9bd9f2622f36e842b3be.zip |
better error than NullPointerException when directory does not exist
Diffstat (limited to 'stage1')
-rw-r--r-- | stage1/Stage1.scala | 4 | ||||
-rw-r--r-- | stage1/cbt.scala | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/stage1/Stage1.scala b/stage1/Stage1.scala index 62cab87..c243cc0 100644 --- a/stage1/Stage1.scala +++ b/stage1/Stage1.scala @@ -92,8 +92,8 @@ object Stage1{ val stage2sourceFiles = ( stage2.listFiles - ++ (stage2 / "plugins").listFiles - ++ (cbtHome / "libraries" / "eval").listFiles + ++ (stage2 / "plugins").listOrFail + ++ (cbtHome / "libraries" / "eval").listOrFail ).filter(_.isFile).filter(_.toString.endsWith(".scala")) val cls = this.getClass.getClassLoader.loadClass("cbt.NailgunLauncher") diff --git a/stage1/cbt.scala b/stage1/cbt.scala index b97ad44..8cba9df 100644 --- a/stage1/cbt.scala +++ b/stage1/cbt.scala @@ -62,6 +62,7 @@ object `package`{ file.delete } + def listOrFail: Seq[File] = Option( file.listFiles ).getOrElse( throw new Exception( "no such file: " + file ) ).toVector def listRecursive: Seq[File] = { file +: ( if( file.isDirectory ) file.listFiles.flatMap(_.listRecursive).toVector else Seq[File]() |