Skip to content

Commit

Permalink
Handle CompilationErrors correctly on job creation
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Rögner <[email protected]>
  • Loading branch information
roegi committed Dec 20, 2024
1 parent 70afd7e commit 8f21644
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@
import com.here.xyz.jobs.Job;
import com.here.xyz.jobs.RuntimeStatus;
import com.here.xyz.jobs.datasets.DatasetDescription;
import com.here.xyz.jobs.steps.JobCompiler.CompilationError;
import com.here.xyz.jobs.steps.inputs.Input;
import com.here.xyz.jobs.steps.inputs.InputsFromJob;
import com.here.xyz.jobs.steps.inputs.InputsFromS3;
import com.here.xyz.jobs.steps.inputs.ModelBasedInput;
import com.here.xyz.jobs.steps.inputs.UploadUrl;
import com.here.xyz.jobs.steps.outputs.Output;
import com.here.xyz.util.service.BaseHttpServerVerticle.ValidationException;
import com.here.xyz.util.service.HttpException;
import com.here.xyz.util.service.rest.Api;
import io.vertx.core.Future;
Expand Down Expand Up @@ -75,6 +77,7 @@ protected void postJob(final RoutingContext context) throws HttpException {
Job job = getJobFromBody(context);
job.create().submit()
.map(res -> job)
.recover(t -> Future.failedFuture(t instanceof CompilationError e ? new ValidationException(e.getMessage(), e) : t))
.onSuccess(res -> sendResponse(context, CREATED.code(), res))
.onFailure(err -> sendErrorResponse(context, err));
}
Expand Down

0 comments on commit 8f21644

Please sign in to comment.