You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
MahdiBM
changed the title
A way to report of "error" situations
A way to have a report of error situations
Jul 16, 2024
I could make the render function throwing. Seems odd to add a task local to store errors. Although these could be considered warnings I guess. The other thing that could cause a warning is missed variables ie {{var}} when var doesn't exist.
Yeah using task locals is odd, but I guess that was the best I could come up with without manipulating swift-mustache, in EnumeratorMacro.
EnumeratorMacro is now using pretty much only internal wrapper types so it can have full control over transforms etc... so this is no longer an issue for me, because I won't be falling back to swift-mustache's transforms.
But it is still a question if swift-mustache should report errors better anyways and not be loose like in JS. Possibly having an option to configure.
I just implemented this for EnumeratorMacro:
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#L50Which 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.The text was updated successfully, but these errors were encountered: