Files
clang-uml/docs/test_cases/t20023.md
2022-12-13 00:34:23 +01:00

1.1 KiB

t20023 - Try/catch statement sequence diagram test case

Config

compilation_database_dir: ..
output_directory: puml
diagrams:
  t20023_sequence:
    type: sequence
    glob:
      - ../../tests/t20023/t20023.cc
    include:
      namespaces:
        - clanguml::t20023
    using_namespace:
      - clanguml::t20023
    start_from:
      - function: "clanguml::t20023::tmain()"

Source code

File t20023.cc

#include <stdexcept>

namespace clanguml {
namespace t20023 {

struct A {
    int a1() { return 1; }
    int a2() { return 2; }
    int a3() { return 3; }
    int a4() { return 3; }

    int a()
    {
        try {
            return a1();
        }
        catch (std::runtime_error &) {
            return a2();
        }
        catch (std::logic_error &) {
            return a3();
        }
        catch (...) {
            return a4();
        }
    }
};

int tmain()
{
    A a;

    int result{};

    result = a.a();

    return result;
}
}
}

Generated UML diagrams

t20023_sequence