Skip to content

Add .stack property and stack_string() method to exceptions #49

@mjm918

Description

@mjm918

Summary

Add stack trace capture to exceptions for better debugging. Currently exceptions only have .message() method.

Sub-issues

This feature has been split into smaller, focused issues:

Dependency Graph

#55 (.message property)     #56 (stack_frame type)
         |                          |
         |                          v
         |                  #57 (shadow stack runtime)
         |                          |
         |                          v
         |                  #58 (.stack property)
         |                          |
         |                          v
         +------------------#59 (stack_string() method)

Implementation Order

  1. Change exception .message() method to .message property #55 - .message().message (can be done independently)
  2. Add stack_frame built-in type #56 - stack_frame type (foundation for stack traces)
  3. Implement shadow stack runtime for stack traces #57 - Shadow stack runtime (depends on Add stack_frame built-in type #56)
  4. Add .stack property to exceptions #58 - .stack property (depends on Add stack_frame built-in type #56, Implement shadow stack runtime for stack traces #57)
  5. Add stack_string() method to exceptions #59 - stack_string() method (depends on Add .stack property to exceptions #58)

Final API

exception DivisionByZero {
    dividend: int,
}

fn main() {
    divide(10, 0) catch e {
        println(e.message);           // Property (changed from method)
        println(e.stack_string());    // Formatted stack trace
        
        // Or iterate frames:
        for (i: int, frame: stack_frame in e.stack) {
            println("{} at {}:{}", frame.function, frame.file, frame.line);
        }
    };
}

Completion Criteria

This tracking issue will be closed when all sub-issues are completed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions