Skip to content

Hint on overly broad exception handler #23367

Open
@arnetheduck

Description

@arnetheduck

Summary

Introduce a hint when exception handler catches a broader exception type than is raised

Description

Similar to #23366 but distinct in semantics, an exception handler that catches more exceptions than necessary may introduce unexpected runtime behavior when dependent code changes:

proc f() {.raises: [ValueError].} = 
  raise (ref ValueError)()

try:
  f()
except CatchableError: # Only ValueError is raised here which is more specific 
  discard

Alternatives

No response

Examples

No response

Backwards Compatibility

No response

Links

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions