refactor: introduce exit-code guard against InternalError

This commit is contained in:
Gleb Koval 2025-02-13 23:39:07 +00:00
parent 756b42dd72
commit b7e442b269
Signed by: cyclane
GPG Key ID: 15E168A8B332382C

View File

@ -39,8 +39,15 @@ def compile(contents: String): Int = {
typeChecker.check(prog)
if (errors.result.nonEmpty) {
given errorContent: String = contents
errors.result.foreach(printError)
200
errors.result
.map { error =>
printError(error)
error match {
case _: Error.InternalError => 201
case _ => 200
}
}
.max()
} else 0
case Failure(msg) =>
println(msg)