Skip to content

Commit

Permalink
fix(Kayenta): Change exception type to kork.UserException (#3218)
Browse files Browse the repository at this point in the history
* fix(Kayenta): Change exception type to kork.UserException
  • Loading branch information
nisanharamati committed Oct 8, 2019
1 parent e872ce8 commit fd18516
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.netflix.spinnaker.orca.kayenta.tasks

import com.netflix.spinnaker.kork.exceptions.UserException
import com.netflix.spinnaker.orca.ExecutionStatus.SUCCEEDED
import com.netflix.spinnaker.orca.Task
import com.netflix.spinnaker.orca.TaskResult
Expand All @@ -25,9 +26,9 @@ class ResolveKayentaConfigIdTask(
.toList()

if (candidates.size == 0) {
throw NoSuchElementException("Couldn't find a configId for configName $configName and application $currentApplication")
throw UserException("Couldn't find a canary configId for configName $configName and application $currentApplication")
} else if (candidates.size > 1) {
throw IllegalArgumentException("Found more than one configId for configName $configName and application $currentApplication")
throw UserException("Found more than one canary configId for configName $configName and application $currentApplication")
}
return TaskResult.builder(SUCCEEDED).context("canaryConfigId", candidates[0].id).build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.orca.kayenta.tasks

import com.netflix.spinnaker.kork.exceptions.UserException
import com.netflix.spinnaker.orca.ExecutionStatus.SUCCEEDED
import com.netflix.spinnaker.orca.Task
import com.netflix.spinnaker.orca.TaskResult
Expand All @@ -38,7 +39,7 @@ class RunKayentaCanaryTask(
val context = stage.mapTo<RunCanaryContext>()

if (context.canaryConfigId.isNullOrEmpty()) {
throw IllegalArgumentException("Invalid canaryConfigId. Was the correct configName or configId used?")
throw UserException("Invalid canaryConfigId. Was the correct configName or configId used?")
}

val canaryPipelineExecutionId = kayentaService.create(
Expand Down

0 comments on commit fd18516

Please sign in to comment.