Skip to content

Commit

Permalink
Merge pull request #257 from buerokratt/250-ruuter-error-handling
Browse files Browse the repository at this point in the history
#250 REHA: also log when DSL returns non-OK
  • Loading branch information
RayDNoper authored Jan 26, 2024
2 parents 90db976 + e4b7134 commit 22ff64e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/ee/buerokratt/ruuter/domain/DslInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ private void executeStep(String stepName, List<String> stepNames) {
if (!Objects.equals(recursions.get(stepName), getStepMaxRecursions(stepToExecute))) {
try {
stepToExecute.execute(this);
if (getErrorStatus() != null && !getErrorStatus().equals(HttpStatus.OK)) {
logEvent(stepToExecute, "RUNTIME", Thread.currentThread().getStackTrace());
}
} catch (StepExecutionException e) {
logEvent(stepToExecute, "RUNTIME", e.getStackTrace());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.HttpStatus;
import org.springframework.web.client.HttpClientErrorException;

@Slf4j
@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.http.HttpStatus;
import org.springframework.web.client.HttpClientErrorException;

import java.util.HashMap;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -33,6 +35,10 @@ protected void executeStepAction(DslInstance di) {
di.setReturnStatus(status);
di.setReturnWithWrapper(withWrapper);
di.setReturnValue(di.getScriptingHelper().evaluateScripts(returnValue, di.getContext(), di.getRequestBody(), di.getRequestQuery(), di.getRequestHeaders()));
if (status != 200) {
di.setErrorStatus(HttpStatus.valueOf(status));
di.setErrorMessage(returnValue);
}
}

@Override
Expand Down

0 comments on commit 22ff64e

Please sign in to comment.