Skip to content

Commit

Permalink
TypesafeXMLEventReader: Give a more helpful message when invalid char…
Browse files Browse the repository at this point in the history
…acter for charset.
  • Loading branch information
kingjon3377 committed Nov 1, 2020
1 parent c88f5c9 commit 3620954
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/lovelace/util/jvm/TypesafeXMLReader.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import java.lang {
JBoolean=Boolean
}

import java.nio.charset {
MalformedInputException
}

"""A wrapper around [[XMLEventReader]] that hides its "raw type" from callers,
additionally satisfying [[the Ceylon Iterable interface|Iterable]] instead
of [[the Java Iterable interface|java.lang::Iterable]]. Also contains
Expand Down Expand Up @@ -77,7 +81,12 @@ shared class TypesafeXMLEventReader satisfies Iterator<XMLEvent>&Destroyable {
return finished;
}
} catch (XMLStreamException exception) {
throw MalformedXMLException(exception);
value cause = exception.cause;
if (is MalformedInputException cause) {
throw MalformedXMLException(cause, "Invalid character in map file, probably a different encoding.");
} else {
throw MalformedXMLException(exception);
}
}
}
}
Expand Down

0 comments on commit 3620954

Please sign in to comment.