diff options
Diffstat (limited to 'opendc-web/opendc-web-api/src')
| -rw-r--r-- | opendc-web/opendc-web-api/src/main/kotlin/org/opendc/web/api/rest/runner/JobResource.kt | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/opendc-web/opendc-web-api/src/main/kotlin/org/opendc/web/api/rest/runner/JobResource.kt b/opendc-web/opendc-web-api/src/main/kotlin/org/opendc/web/api/rest/runner/JobResource.kt index 7e31e2c5..d9923505 100644 --- a/opendc-web/opendc-web-api/src/main/kotlin/org/opendc/web/api/rest/runner/JobResource.kt +++ b/opendc-web/opendc-web-api/src/main/kotlin/org/opendc/web/api/rest/runner/JobResource.kt @@ -60,6 +60,13 @@ class JobResource @Inject constructor(private val jobService: JobService) { @Path("{job}") @Transactional fun update(@PathParam("job") id: Long, @Valid update: Job.Update): Job { - return jobService.updateState(id, update.state, update.results) ?: throw WebApplicationException("Job not found", 404) + return try { + jobService.updateState(id, update.state, update.results) + ?: throw WebApplicationException("Job not found", 404) + } catch (e: IllegalArgumentException) { + throw WebApplicationException(e, 400) + } catch (e: IllegalStateException) { + throw WebApplicationException(e, 409) + } } } |
