Again, error naming.
This commit is contained in:
parent
51bdcc3ba4
commit
624bd549f3
@ -22,7 +22,7 @@ data IPv6Error
|
||||
= IP6TooManyHexaDecimalCharacters
|
||||
| IP6NotEnoughChunks
|
||||
| IP6TooManyChunks
|
||||
| IP6UnrelevantShortRepresentation
|
||||
| IP6IrrelevantShortRepresentation
|
||||
|
||||
-- | `ipv6_chunk` parses just a group of hexadecimal characters.
|
||||
-- | Return an error (IP6TooManyHexaDecimalCharacters) in case the group has more than 4 characters.
|
||||
@ -72,7 +72,7 @@ ipv6_shortened =
|
||||
let nb_zero_filling = 8 - (A.length chunks_part1 + A.length chunks_part2)
|
||||
filling = repeat nb_zero_filling "0000"
|
||||
if nb_zero_filling < 1
|
||||
then Parser \_ -> failureError pos (Just IP6UnrelevantShortRepresentation)
|
||||
then Parser \_ -> failureError pos (Just IP6IrrelevantShortRepresentation)
|
||||
else pure $ A.fold (A.intersperse ":" $ A.concat [chunks_part1, filling, chunks_part2])
|
||||
|
||||
-- | TODO: accept IPv6 addresses between brackets ([ipv6]).
|
||||
@ -81,7 +81,7 @@ ipv6 = ipv6_shortened <|> ipv6_full
|
||||
|
||||
data IPv4Error
|
||||
= IP4NumberTooBig Int
|
||||
| IP4UnrelevantShortRepresentation
|
||||
| IP4IrrelevantShortRepresentation
|
||||
|
||||
-- | `ipv4_byte` a parser for 0 to 255 natural integers, which is part of the representation of an IPv4 address.
|
||||
ipv4_byte :: Parser IPv4Error Int
|
||||
@ -122,7 +122,7 @@ ipv4_shortened =
|
||||
nb_zero_filling = 4 - (A.length chunks_part1 + A.length chunks_part2)
|
||||
filling = A.fold (A.intersperse "." $ repeat nb_zero_filling "0")
|
||||
if nb_zero_filling < 1
|
||||
then Parser \_ -> failureError pos (Just IP4UnrelevantShortRepresentation)
|
||||
then Parser \_ -> failureError pos (Just IP4IrrelevantShortRepresentation)
|
||||
else pure $ A.fold (A.intersperse "." [part1, filling, part2])
|
||||
|
||||
ipv4 :: Parser IPv4Error String
|
||||
|
@ -68,15 +68,14 @@ test_series :: forall e v
|
||||
test_series l p v e a = foreachE a (\s -> logtest l p s v e)
|
||||
|
||||
showerror_ipv6 :: IP.IPv6Error -> String
|
||||
showerror_ipv6 (IP.InvalidCharacter) = "InvalidCharacter"
|
||||
showerror_ipv6 (IP.TooManyHexaDecimalCharacters) = "TooManyHexaDecimalCharacters"
|
||||
showerror_ipv6 (IP.NotEnoughChunks) = "NotEnoughChunks"
|
||||
showerror_ipv6 (IP.TooManyChunks) = "TooManyChunks"
|
||||
showerror_ipv6 IP.IPv6UnrelevantShortRepresentation = "useless double dots"
|
||||
showerror_ipv6 (IP.IP6TooManyHexaDecimalCharacters) = "TooManyHexaDecimalCharacters"
|
||||
showerror_ipv6 (IP.IP6NotEnoughChunks) = "NotEnoughChunks"
|
||||
showerror_ipv6 (IP.IP6TooManyChunks) = "TooManyChunks"
|
||||
showerror_ipv6 IP.IP6IrrelevantShortRepresentation = "useless double dots"
|
||||
|
||||
showerror_ipv4 :: IP.IPv4Error -> String
|
||||
showerror_ipv4 (NumberTooBig x) = "value '" <> show x <> "' is > 255"
|
||||
showerror_ipv4 IPv4UnrelevantShortRepresentation = "useless double dots"
|
||||
showerror_ipv4 (IP4NumberTooBig x) = "value '" <> show x <> "' is > 255"
|
||||
showerror_ipv4 IP4IrrelevantShortRepresentation = "useless double dots"
|
||||
|
||||
showerror_email :: E.EmailError -> String
|
||||
showerror_email E.InvalidCharacter = "InvalidCharacter"
|
||||
|
Loading…
Reference in New Issue
Block a user