Search in sources :

Example 6 with ProblemBuilder

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder in project halyard by spinnaker.

the class OrcaRunner method findError.

private static Problem findError(HasContext hasContext) {
    if (hasContext == null) {
        return null;
    }
    Context context = hasContext.getContext();
    if (context == null) {
        return null;
    }
    ExecutionException exception = context.getException();
    if (exception == null) {
        return null;
    }
    StringBuilder message = new StringBuilder();
    String operation = exception.getOperation();
    if (operation != null) {
        message.append(formatId(operation)).append(": ");
    }
    ExecutionException.Details details = exception.getDetails();
    if (details == null) {
        message.append("No error details found.");
    } else {
        message.append("(").append(details.getError()).append(") ");
        for (String error : details.getErrors()) {
            message.append(error).append(" ");
        }
    }
    return new ProblemBuilder(Problem.Severity.FATAL, message.toString()).build();
}
Also used : ProblemBuilder(com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder)

Example 7 with ProblemBuilder

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder in project halyard by spinnaker.

the class GoogleWriteableProfileRegistry method writeTextObject.

private void writeTextObject(String name, String contents) {
    try {
        byte[] bytes = contents.getBytes();
        StorageObject object = new StorageObject().setBucket(spinconfigBucket).setName(name);
        ByteArrayContent content = new ByteArrayContent("application/text", bytes);
        storage.objects().insert(spinconfigBucket, object, content).execute();
    } catch (IOException e) {
        log.error("Failed to write new object " + name, e);
        throw new HalException(new ProblemBuilder(Severity.FATAL, "Failed to write to " + name + ": " + e.getMessage()).build());
    }
}
Also used : StorageObject(com.google.api.services.storage.model.StorageObject) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) IOException(java.io.IOException) ByteArrayContent(com.google.api.client.http.ByteArrayContent) ProblemBuilder(com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder)

Example 8 with ProblemBuilder

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder in project halyard by spinnaker.

the class DaemonTask method failure.

public void failure(Exception e) {
    inFailedState();
    fatalError = e;
    Problem problem = new ProblemBuilder(Problem.Severity.FATAL, "Unexpected exception: " + e).build();
    response = new DaemonResponse<>(null, new ProblemSet(problem));
}
Also used : Problem(com.netflix.spinnaker.halyard.core.problem.v1.Problem) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) ProblemBuilder(com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder)

Aggregations

ProblemBuilder (com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder)8 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)6 IOException (java.io.IOException)3 Problem (com.netflix.spinnaker.halyard.core.problem.v1.Problem)2 FileInputStream (java.io.FileInputStream)2 RetrofitError (retrofit.RetrofitError)2 ByteArrayContent (com.google.api.client.http.ByteArrayContent)1 StorageObject (com.google.api.services.storage.model.StorageObject)1 AtomicFileWriter (com.netflix.spinnaker.halyard.core.AtomicFileWriter)1 DaemonResponse (com.netflix.spinnaker.halyard.core.DaemonResponse)1 RemoteAction (com.netflix.spinnaker.halyard.core.RemoteAction)1 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)1 RunningServiceDetails (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.RunningServiceDetails)1 SpinnakerRuntimeSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings)1 Orca (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.OrcaService.Orca)1 ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)1 SpinnakerService (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService)1 DistributedService (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.DistributedService)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1