Skip to content

Support :error tuples as a valid return value in event handlers #80

Description

@marcelotto

Maybe I'm missing something, but is there a way to stop parsing with a :error tuple which is directly passed through as the overall result?

I'm using Saxy for writing an RDF/XML parser which imposes some further restrictions on a valid document. So, I'd like to return a :error tuple in the event handlers when encountering an error, which I'd expect to be passed through directly as the result of Saxy.parse_string/3, but currently this results in this:

{:error,
    %Saxy.ParseError{
      __exception__: true,
      binary: nil,
      position: nil,
      reason: {:bad_return, {:start_element, {:error, "my custom error"}}}
    }
  }
}

I'm aware of the :halt and :stop return patterns, which could be used for this scenario of course, but neither of them feels quite right:

  • with :stop the :error tuple is wrapped in a :ok tuple
  • with :halt the :error tuple is wrapped in a three element :halt tuple

What do you think of supporting :error tuples as an additional return pattern in the handlers, which will become the result of Saxy.parse_string/3 directly?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions