#include <xtd/diagnostics/stack_trace>
#include <xtd/console>
 
 
class stack_trace_sample {
public:
  void my_public_method() {
    my_protected_method();
  }
  
protected:
  void my_protected_method() {
    auto mic = my_internal_class {};
    mic.throws_exception();
  }
  
private:
  class my_internal_class {
  public:
    void throws_exception() {
      try {
        
        string stack_indent = "";
        for (auto i = 0ul; i < st.frame_count(); i++) {
          
          console::write_line();
          console::write_line(stack_indent + " Method: {0}", sf.get_method());
          console::write_line(stack_indent + " File: {0}", sf.get_file_name());
          console::write_line(stack_indent + " Line Number: {0}", sf.get_file_line_number());
          stack_indent += "  ";
        }
        throw;
      }
    }
  };
};
 
auto main() -> int {
  auto sample = stack_trace_sample {};
  try {
    sample.my_public_method();
    
    for (
auto i = 0ul; 
i < st.frame_count(); 
i++) {
 
      
      console::write_line();
      console::write_line("High up the call stack, Method: {0}", sf.get_method());
      
      console::write_line("High up the call stack, Line Number: {0}", sf.get_file_line_number());
    }
  }
}
 
Represents a stack trace, which is an ordered collection of one or more stack frames.
Definition stack_trace.hpp:40
 
const xtd::diagnostics::stack_frame & get_frame(size_t index) noexcept
Gets the specified stack frame.
 
The exception that is thrown when a method call is invalid for the object's current state.
Definition system_exception.hpp:18
 
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
 
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10