-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: forward Zeebe client exceptions to the web UI (#353)
* new: forwarding/pushing ZeebeClient errors to the web UI new: allow multiple errors, info and success messages displayed at once fix: closing error panel also closes info panel (now each panel must be closed individually) change: when during incident resolving the job can't be changed, there's still an attempt to resolve the incident
- Loading branch information
Showing
11 changed files
with
312 additions
and
96 deletions.
There are no files selected for viewing
51 changes: 33 additions & 18 deletions
51
src/main/java/io/zeebe/monitor/rest/ExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,52 @@ | ||
package io.zeebe.monitor.rest; | ||
|
||
import io.camunda.zeebe.client.api.command.ClientException; | ||
import io.zeebe.monitor.rest.ui.ErrorMessage; | ||
import org.apache.commons.lang3.exception.ExceptionUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.context.request.WebRequest; | ||
|
||
@ControllerAdvice | ||
public class ExceptionHandler { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(ExceptionHandler.class); | ||
private static final Logger LOG = LoggerFactory.getLogger(ExceptionHandler.class); | ||
|
||
private final WhitelabelProperties whitelabelProperties; | ||
private final WhitelabelProperties whitelabelProperties; | ||
|
||
public ExceptionHandler(WhitelabelProperties whitelabelProperties) { | ||
this.whitelabelProperties = whitelabelProperties; | ||
} | ||
public ExceptionHandler(WhitelabelProperties whitelabelProperties) { | ||
this.whitelabelProperties = whitelabelProperties; | ||
} | ||
|
||
@org.springframework.web.bind.annotation.ExceptionHandler(RuntimeException.class) | ||
public String handleRuntimeException(RuntimeException exc, final Model model) { | ||
LOG.error(exc.getMessage(), exc); | ||
@org.springframework.web.bind.annotation.ExceptionHandler(value = {ClientException.class}) | ||
protected ResponseEntity<Object> handleZeebeClientException(final RuntimeException ex, final WebRequest request) { | ||
LOG.debug("Zeebe Client Exception caught and forwarding to UI.", ex); | ||
return ResponseEntity | ||
.status(HttpStatus.FAILED_DEPENDENCY) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.body(new ErrorMessage(ex.getMessage())); | ||
} | ||
|
||
model.addAttribute("error", exc.getClass().getSimpleName()); | ||
model.addAttribute("message", exc.getMessage()); | ||
model.addAttribute("trace", ExceptionUtils.getStackTrace(exc)); | ||
@org.springframework.web.bind.annotation.ExceptionHandler(RuntimeException.class) | ||
public String handleRuntimeException(final RuntimeException exc, final Model model) { | ||
LOG.error(exc.getMessage(), exc); | ||
|
||
model.addAttribute("custom-title", whitelabelProperties.getCustomTitle()); | ||
model.addAttribute("context-path", whitelabelProperties.getBasePath()); | ||
model.addAttribute("logo-path", whitelabelProperties.getLogoPath()); | ||
model.addAttribute("custom-css-path", whitelabelProperties.getCustomCssPath()); | ||
model.addAttribute("custom-js-path", whitelabelProperties.getCustomCssPath()); | ||
model.addAttribute("error", exc.getClass().getSimpleName()); | ||
model.addAttribute("message", exc.getMessage()); | ||
model.addAttribute("trace", ExceptionUtils.getStackTrace(exc)); | ||
|
||
return "error"; | ||
} | ||
model.addAttribute("custom-title", whitelabelProperties.getCustomTitle()); | ||
model.addAttribute("context-path", whitelabelProperties.getBasePath()); | ||
model.addAttribute("logo-path", whitelabelProperties.getLogoPath()); | ||
model.addAttribute("custom-css-path", whitelabelProperties.getCustomCssPath()); | ||
model.addAttribute("custom-js-path", whitelabelProperties.getCustomCssPath()); | ||
|
||
return "error"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.zeebe.monitor.rest.ui; | ||
|
||
public class ErrorMessage { | ||
|
||
private String message; | ||
|
||
public ErrorMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(final String message) { | ||
this.message = message; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...tor/rest/ProcessInstanceNotification.java → .../rest/ui/ProcessInstanceNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package io.zeebe.monitor.rest; | ||
package io.zeebe.monitor.rest.ui; | ||
|
||
public class ProcessInstanceNotification { | ||
|
||
|
29 changes: 29 additions & 0 deletions
29
src/main/java/io/zeebe/monitor/rest/ui/ZeebeClusterNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.zeebe.monitor.rest.ui; | ||
|
||
public class ZeebeClusterNotification { | ||
|
||
private Type type; | ||
private String message; | ||
|
||
public enum Type { | ||
INFORMATION, | ||
SUCCESS, | ||
ERROR | ||
} | ||
|
||
public Type getType() { | ||
return type; | ||
} | ||
|
||
public void setType(final Type type) { | ||
this.type = type; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(final String message) { | ||
this.message = message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.