Skip to content

A way to have a report of error situations #40

@MahdiBM

Description

@MahdiBM

I just implemented this for EnumeratorMacro:

Screenshot 2024-07-16 at 10 46 36 PM

This will basically report back if a function call is invalid, and won't result in a silent failure.
Note that this is only possible because EnumeratorMacro defines its own wrapper types to have control over the transforms.

How it works is using a TaskLocal: https://github.com/MahdiBM/enumerator-macro/blob/0a1b67d2941dec346f59f06d0c7c86888712aae0/Sources/EnumeratorMacroImpl/EnumeratorMacroType.swift#L50
Which are used to store an error: https://github.com/MahdiBM/enumerator-macro/blob/0a1b67d2941dec346f59f06d0c7c86888712aae0/Sources/EnumeratorMacroImpl/Types/EString.swift#L70

I think swift-mustache can also have such an option. If the user has inserted a value for the TaskLocal, swift-mustache will populate it. swift-mustache seems a nil task-local value and just moves on with the current behavior.
The TaskLocal should be defined in swift-mustache, but it just defaults to nil which would result in no capturing of errors.

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