You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2021/06/21 11:56:28 UTC
[GitHub] [daffodil] stevedlawrence commented on a change in pull request #592: Added different exit codes to Daffodil command line
stevedlawrence commented on a change in pull request #592:
URL: https://github.com/apache/daffodil/pull/592#discussion_r655310578
##########
File path: daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala
##########
@@ -1584,35 +1584,35 @@ object Main extends Logging {
} catch {
case s: scala.util.control.ControlThrowable => throw s
case e: java.io.FileNotFoundException => {
- log(LogLevel.Error, "%s", e.getMessage())
+ log(LogLevel.Error, "Missing File Error", e.getMessage())
1
}
case e: InvalidParserException => {
- log(LogLevel.Error, "%s", e.getMessage())
- 1
+ log(LogLevel.Error, "Invalid Parser Error", e.getMessage())
+ 2
}
case e: ExternalVariableException => {
- log(LogLevel.Error, "%s", e.getMessage())
- 1
+ log(LogLevel.Error, "External Variable Error", e.getMessage())
+ 3
}
case e: BindingException => {
- log(LogLevel.Error, "%s", e.getMessage())
- 1
+ log(LogLevel.Error, "Binding Error", e.getMessage())
+ 4
}
case e: NotYetImplementedException => {
nyiFound(e)
}
case e: TDMLException => {
- log(LogLevel.Error, "%s", e.getMessage())
- 1
+ log(LogLevel.Error, "TDML Error", e.getMessage())
+ 5
}
case e: OutOfMemoryError => {
oomError(e)
}
case e: UserDefinedFunctionFatalErrorException => {
- log(LogLevel.Error, "%s", e.getMessage())
+ log(LogLevel.Error, "User Error", e.getMessage())
e.printStackTrace()
- 1
+ 6
Review comment:
Instead of having all these magic numbers spread out, I would suggest we create some vals so that these are self documenting. e.g. val USER_DEFINED_FUNCTION_ERROR_CODE. That way all the codes can be define in one spot and used throughout.
##########
File path: daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala
##########
@@ -1584,35 +1584,35 @@ object Main extends Logging {
} catch {
case s: scala.util.control.ControlThrowable => throw s
case e: java.io.FileNotFoundException => {
- log(LogLevel.Error, "%s", e.getMessage())
+ log(LogLevel.Error, "Missing File Error", e.getMessage())
1
}
case e: InvalidParserException => {
- log(LogLevel.Error, "%s", e.getMessage())
- 1
+ log(LogLevel.Error, "Invalid Parser Error", e.getMessage())
+ 2
}
case e: ExternalVariableException => {
- log(LogLevel.Error, "%s", e.getMessage())
- 1
+ log(LogLevel.Error, "External Variable Error", e.getMessage())
+ 3
}
case e: BindingException => {
- log(LogLevel.Error, "%s", e.getMessage())
- 1
+ log(LogLevel.Error, "Binding Error", e.getMessage())
+ 4
}
case e: NotYetImplementedException => {
nyiFound(e)
}
case e: TDMLException => {
- log(LogLevel.Error, "%s", e.getMessage())
- 1
+ log(LogLevel.Error, "TDML Error", e.getMessage())
+ 5
}
case e: OutOfMemoryError => {
oomError(e)
}
case e: UserDefinedFunctionFatalErrorException => {
- log(LogLevel.Error, "%s", e.getMessage())
+ log(LogLevel.Error, "User Error", e.getMessage())
e.printStackTrace()
- 1
+ 6
}
case e: Exception => {
bugFound(e)
Review comment:
A similar change is needed as nyiFound.
##########
File path: daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala
##########
@@ -1584,35 +1584,35 @@ object Main extends Logging {
} catch {
case s: scala.util.control.ControlThrowable => throw s
case e: java.io.FileNotFoundException => {
- log(LogLevel.Error, "%s", e.getMessage())
+ log(LogLevel.Error, "Missing File Error", e.getMessage())
Review comment:
I imagine in this case and the ones below, the message from the exception is what we want to display. This new strings dont' provide enough information. For example, the message I get when we hit this FileNotFoundException is
> [error] notafile.txt (No such file or directory)
Which is maybe a bit terse, but I think provides all the necessary information. We probably want CLI tests to make sure we are getting reasonable error messages.
##########
File path: daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala
##########
@@ -1584,35 +1584,35 @@ object Main extends Logging {
} catch {
case s: scala.util.control.ControlThrowable => throw s
case e: java.io.FileNotFoundException => {
- log(LogLevel.Error, "%s", e.getMessage())
+ log(LogLevel.Error, "Missing File Error", e.getMessage())
1
}
case e: InvalidParserException => {
- log(LogLevel.Error, "%s", e.getMessage())
- 1
+ log(LogLevel.Error, "Invalid Parser Error", e.getMessage())
+ 2
}
case e: ExternalVariableException => {
- log(LogLevel.Error, "%s", e.getMessage())
- 1
+ log(LogLevel.Error, "External Variable Error", e.getMessage())
+ 3
}
case e: BindingException => {
- log(LogLevel.Error, "%s", e.getMessage())
- 1
+ log(LogLevel.Error, "Binding Error", e.getMessage())
+ 4
}
case e: NotYetImplementedException => {
nyiFound(e)
Review comment:
Note that the nyiFound function returns an int, which is the return code. So either that function needs to return a different code, or it shouldn't return a code at all, and this should return a number.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org