umlplantumlactivity-diagram

Is there a way to stop the flow after a repeat while loop with breaks in a plantuml diagram?


I have a process I'm trying to represent with a PlantUML activity diagram and I hit upon a frustrating limitation with the repeat while structure. The process is an asynchronous call in which I might receive some errors. If there are errors and the errors are recognised, I want to make the call again, otherwise I want to stop the process altogether. Thus I represented this with a repeat while loop. If there are no errors, I break out the loop entirely. The diagram I have now is: current diagram with code:

@startuml
start

repeat
    :Sync process begins;

    -[dashed]-> asynchronous;
    :Receive callback;

    if (Error in callback?) then (no)
        #GreenYellow:Process continues normally;
        break
    else (yes)
    endif
repeat while (Error is recognised?) is (yes)

:Continue normal road;

end
@enduml

Edit: Note: the Continue normal road node is in fact not just a node, but my main application logic, which is complicated, so for ease of readability of the diagram, I need a solution which ends the repeat loop at this level of the diagram, not later.

The problem is that this doesn't fully represent the flow I described, because it suggests that even if the error is not recognised, the process continues. What I would like to do is get rid of that error between the "Error is recognised?" node and the empty node beneath it, but it's very frustating that it seems I have no control over that arrow!

If I try to dash that arrow, for example, then the next arrow gets dashed, the one between the empty node and "Continue normal road".

I'm attaching a second picture to make it easier to see which arrow I want removed to represent my actual flow.

emphasis on what I want removed from diagram

Is there any way to achieve this? Or will I have to settle on doing something like

repeat while (Error is recognised?) is (yes) not (ignore this arrow, can't remove it but it shouldn't be here)

Solution

  • The repeat-while loop does what it has to do, you are not in front of a limitation, your way to do is just wrong.

    If I well understand your goal you can do like that :

    @startuml
    start
    
    repeat
        :Sync process begins;
    
        -[dashed]-> asynchronous;
        :Receive callback;
    
        if (Error in callback?) then (no)
            #GreenYellow:Process continues normally;
            :Continue normal road;
            end
            
        else (yes)
        endif
    repeat while (Error is recognised?) is (yes)
    detach
    
    @enduml
    

    producing :

    enter image description here

    strictly doing what you asked, so nothing in case the error is not recognized else replace detach by something else.

    Apart of that, your mix between synchronous and asynchronous part is very obscure and probably wrong, also the way to read an event, then this is not the right way to define the activity you want, furthermore it does not need an explicit loop. But your question is not about that.