Action diagram with common recovery action

0 votes
asked May 25, 2022 in Question / help by mcon (320 points)

I need to use a verticalif-like configuration:

@startuml
!pragma useverticalif on
start
if (test1) then (error)
:;
elseif (test2) then (error)
:;
elseif (test3) then (error)
:;
elseif (test4) then (error)
:;
elseif (test5) then (error)
:;
elseif (test6) then (error)
:;
elseif (test7) then (error)
:do some;
:error recovery;
endif
stop
@enduml

My problem is I need all "error" branches to go to the same "do some/error recovery" recovery actions while still being able to add further actions in the "else" (no error) "normal flow".

How can I achieve this?

1 Answer

0 votes
answered May 25, 2022 by The-Lu (64,340 points)

Hello M.,

Here are some proposals, with `goto`, as:

Without `useverticalif `:

@startuml
'!pragma useverticalif on
start
if (test1) then (error)
label d0
label d1
label d2
label d3
label d4
label d5
label error
:do some;
:error recovery;
elseif (test2) then (error)
label l2
goto error
elseif (test3) then (error)
label d0
label d1
goto error
elseif (test4) then (error)
label d0
label d1
label d2
goto error
elseif (test5) then (error)
label d0
label d1
label d2
label d3
goto error
elseif (test6) then (error)
label d0
label d1
label d2
label d3
label d4
goto error
elseif (test7) then (error)
label d0
label d1
label d2
label d3
label d4
label d5
goto error
else (no error)
:normal flow;
endif
stop
@enduml

With `useverticalif `:

@startuml
!pragma useverticalif on
start
if (test1) then (error)
label error
elseif (test2) then (error)
goto error
elseif (test3) then (error)
goto error
elseif (test4) then (error)
goto error
elseif (test5) then (error)
goto error
elseif (test6) then (error)
goto error
elseif (test7) then (error)
:do some;
:error recovery;
detach
else (no error)
:normal flow;
endif
stop
@enduml

That is yet not perfect, some overlappings... (to improve by PlantUML team: wink)

See also doc. and wanted feature about goto here:

If that can help,
Regards,

...