Generate an error when parsing a feed with no data
This commit is contained in:
parent
4b404c1de1
commit
dc0f5964a9
|
@ -23,7 +23,13 @@ defmodule FeedParser do
|
|||
"""
|
||||
@spec parse(data :: String.t(), content_type :: String.t(), parsers :: [module()]) ::
|
||||
{:ok, feed :: FeedParser.Feed.t()} | {:error, reason :: String.t()}
|
||||
def parse(data, content_type, parsers \\ @default_parsers) when is_binary(data) do
|
||||
def parse(data, content_type, parsers \\ @default_parsers)
|
||||
|
||||
def parse(nil, _, _) do
|
||||
{:error, "no data"}
|
||||
end
|
||||
|
||||
def parse(data, content_type, parsers) when is_binary(data) do
|
||||
parsers
|
||||
|> Enum.reduce_while(false, fn parser, acc ->
|
||||
case parser.accepts(data, content_type) do
|
||||
|
|
Loading…
Reference in New Issue