Skip to content

Conversation

@trojanc
Copy link
Contributor

@trojanc trojanc commented Jun 7, 2025

Motivation/Abstract

please describe in 1-3 sentences,

I wanted to be able to handle "Technical Error" which should cause the engine to stop executing the process and surface the error. Also I wanted to be able to raise "Business Errors" using Error Events and using Error Boundary Event and Event Sub Processes.

Examples: This is a bug fix for ... ; I want to use this BPMN extension attributes 'X' for my project 'Y'...

Description/Comments

  • Implement "Technical Errors". They are caused by using job.Fail(), when a job fails it now also fails the process instance
  • Implement "Business Errors". They are thrown using job.ThrowError()
  • Implement "Error Boundary Event", specific match, catchall and output mapping
  • Implement "Error Sub Process"
  • Created LogEventExporter which is handy for unit tests to see the sequence that was executed
  • When the engine received an unknown command (which should never happen), it now creates a Technical Error instead of a panic.
  • When an unknown BPMN element is encountered (likely to happen if unsupported elements are used), it now creates a Technical Error instead of a panic.

The following elements are now additional read from the BPMN file

  • Definitions.Errors Defining the errors that can be used in the proccess
  • Process.BoundaryEvent Defines all boundary events and where they are attached

The following flows are implemented:
A service/user task with an attached ErrorBoundaryEvent catching the specific error being thrown
A service/user task with an attached ErrorBoundaryEvent catching all errors
error-boundary-event

A service/user task with 2 attached ErrorBoundaryEvents the specific ErrorBoundaryEvent will be activated, or the "catch-all" ErrorBoundaryEvent if not specifically matched
error-boundary-event-multiple

Event Sub Process can be used to catch the error
error-event-subprocess

If both ErrorBoundaryEvents and Event Sub Process exist. The error will be handled by the handler that best matches the Error Event. See Catching the error
error-boundary-event-and-subprocess

Still not supported:

  • Propagating Error Event up to parent process
  • Error End Event
  • Other types of Event Sub Processes

Checklist

Depending on your PR, please ensure the overall consistency/integrity of the project remains.
Please tick just one check item per section below

Tests

  • did you update or create tests for your code changes?
  • not relevant

Code examples

  • did you update or add example code snippets, which relate to your code changes
  • not relevant

Documentation

  • did you update or create documentation, which relates to your code changes
  • not relevant

@codecov
Copy link

codecov bot commented Jun 7, 2025

Codecov Report

❌ Patch coverage is 83.49515% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.42%. Comparing base (447965f) to head (6d16f50).

Files with missing lines Patch % Lines
pkg/bpmn_engine/engine.go 81.50% 22 Missing and 5 partials ⚠️
pkg/spec/BPMN20/elements.go 80.95% 4 Missing ⚠️
pkg/spec/BPMN20/helper.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #273      +/-   ##
==========================================
+ Coverage   63.81%   66.42%   +2.61%     
==========================================
  Files          28       29       +1     
  Lines        1915     2106     +191     
==========================================
+ Hits         1222     1399     +177     
- Misses        647      661      +14     
  Partials       46       46              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@trojanc trojanc force-pushed the error_handling branch 2 times, most recently from 1ed8c6a to 6bb377c Compare June 7, 2025 16:56
@trojanc
Copy link
Contributor Author

trojanc commented Jun 7, 2025

@nitram509 for this one I wasn't entirely sure what the indended purpose for job.Fail() was, since nothing was done with the error. I wanted to be able to distinquish between Technical Error and Business Errors... I used job.Fail() as a way to indicate a Technical Error and created a new function job.ThrowError() that can be used for Business Errors

@trojanc trojanc force-pushed the error_handling branch 2 times, most recently from 7323aa1 to d989d1e Compare June 7, 2025 17:40
@trojanc trojanc marked this pull request as ready for review June 7, 2025 17:40
@trojanc
Copy link
Contributor Author

trojanc commented Oct 24, 2025

@nitram509 will you take a peak at this one when you have some time please. I've been using it successfully in my own project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant