Skip to content

Commit

Permalink
Rename Raises to Errant
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Apr 8, 2024
1 parent 04fa2f1 commit 8ee184b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/xmlreader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ trait XmlDecoder[ValueType]:
def map[ValueType2](lambda: ValueType => ValueType2): XmlDecoder[ValueType2] = list => lambda(read(list))

object XmlDecoder extends Derivation[XmlDecoder]:
given text(using Raises[XmlReadError]): XmlDecoder[Text] = list =>
given text(using Errant[XmlReadError]): XmlDecoder[Text] = list =>
val elements = childElements(list).collect { case XmlAst.Textual(text) => text }
if elements.length == 0 then raise(XmlReadError())("".tt) else elements.head

Expand Down
6 changes: 3 additions & 3 deletions src/core/xylophone.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ case class XmlNode(head: Int, path: XmlPath, root: XmlAst.Root) extends Xml, Dyn
infix def + (other: Xml): XmlDoc raises XmlAccessError =
XmlDoc(XmlAst.Root(Xml.normalize(this) ++ Xml.normalize(other)*))

def as[ValueType: XmlDecoder](using Raises[XmlReadError], Raises[XmlAccessError]): ValueType =
def as[ValueType: XmlDecoder](using Errant[XmlReadError], Errant[XmlAccessError]): ValueType =
summon[XmlDecoder[ValueType]].read(Xml.normalize(this))

case class XmlDoc(root: XmlAst.Root) extends Xml, Dynamic:
Expand All @@ -200,14 +200,14 @@ case class XmlDoc(root: XmlAst.Root) extends Xml, Dynamic:
infix def + (other: Xml): XmlDoc raises XmlAccessError =
XmlDoc(XmlAst.Root(Xml.normalize(this) ++ Xml.normalize(other)*))

def as[ValueType: XmlDecoder](using Raises[XmlAccessError], Raises[XmlReadError]): ValueType =
def as[ValueType: XmlDecoder](using Errant[XmlAccessError], Errant[XmlReadError]): ValueType =
summon[XmlDecoder[ValueType]].read(Xml.normalize(this))

case class Attribute(node: XmlNode, attribute: Text):
def as
[ValueType]
(using decoder: XmlDecoder[ValueType])
(using Raises[XmlReadError], Raises[XmlAccessError]): ValueType =
(using Errant[XmlReadError], Errant[XmlAccessError]): ValueType =

val attributes = Xml.normalize(node).prim match
case XmlAst.Element(_, _, attributes, _) => attributes
Expand Down

0 comments on commit 8ee184b

Please sign in to comment.