chetanmeh commented on a change in pull request #4584: OpenWhisk User Events
URL: https://github.com/apache/openwhisk/pull/4584#discussion_r326071229
 
 

 ##########
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/entity/ActivationResult.scala
 ##########
 @@ -61,16 +61,25 @@ protected[core] object ActivationResponse extends 
DefaultJsonProtocol {
   val DeveloperError = 2 // action ran but failed to handle an error, or 
action did not run and failed to initialize
   val WhiskError = 3 // internal system error
 
-  protected[core] def messageForCode(code: Int) = {
-    require(code >= Success && code <= WhiskError)
+  val statusSuccess = "success"
+  val statusApplicationError = "application_error"
+  val statusDeveloperError = "action_developer_error"
+  val statusWhiskError = "whisk_internal_error"
+
+  protected[core] def statusForCode(code: Int) = {
+    require(code >= 0 && code <= 3)
     code match {
-      case Success          => "success"
-      case ApplicationError => "application error"
-      case DeveloperError   => "action developer error"
-      case WhiskError       => "whisk internal error"
+      case 0 => ActivationResponse.statusSuccess
+      case 1 => ActivationResponse.statusApplicationError
+      case 2 => ActivationResponse.statusDeveloperError
+      case 3 => ActivationResponse.statusWhiskError
     }
   }
 
+  protected[core] def messageForCode(code: Int) = {
 
 Review comment:
   nit: `messageForCode` is called in critical frequent use path. So to avoid 
unnecessary string computation it may be better to also keep the computed 
values as val and just reuse them

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to