Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Problem_Behavior type #5115

Open
wdanilo opened this issue Feb 5, 2023 · 0 comments
Open

Enhanced Problem_Behavior type #5115

wdanilo opened this issue Feb 5, 2023 · 0 comments
Labels
-libs Libraries: New libraries to be implemented l-problem-behaviour p-low Low priority x-new-feature Type: new feature request

Comments

@wdanilo
Copy link
Member

wdanilo commented Feb 5, 2023

This task is automatically imported from the old Task Issue Board and it was originally created by James Dunkerley.
Original issue is here.


Currently a simple Atom enumeration.

Could become much more like an Error catch

type Problem_Hander
    Ignore = Problem_Handler.Callback (_ value -> value)

    Report_Warning = Problem_Handler.Callback (problem value -> value.attach_warning problem)

    Report_Error = Problem_Handler.Callback (problem _ -> Error.throw problem)

    Callback callback:(Problem->Value->Value) =
        callback problem value = 
            if problem.is_a Encoding_Error then Error.throw problem else
                value.attach_warning problem

    ignore_on : Type -> Problem_Handler
    ignore_on self type =
        callback problem value =
            if problem.is_a type then value else
                self.callback problem value
        Problem_Handler.Callback callback

    warning_on : Type -> Problem_Handler
    warning_on self type =
        callback problem value =
            if problem.is_a type then value.attach_warning problem else
                self.callback problem value
        Problem_Handler.Callback callback

    error_on : Type -> Problem_Handler
    error_on self type =
        callback problem value =
            if problem.is_a type then Error.throw problem else
                self.callback problem value
        Problem_Handler.Callback callback

on_problems=(Report_Warning.ignore_on Encoding_Error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-libs Libraries: New libraries to be implemented l-problem-behaviour p-low Low priority x-new-feature Type: new feature request
Projects
None yet
Development

No branches or pull requests

1 participant