io.github.pidoveproject.showdown.protocol.ProtocolError.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala-showdown-api_3 Show documentation
Show all versions of scala-showdown-api_3 Show documentation
A Scala wrapper of Pokemon Showdown's API
The newest version!
package io.github.pidoveproject.showdown.protocol
/**
* A protocol-bound error
*/
enum ProtocolError(message: String) extends Throwable(message):
/**
* The input has been exhausted.
*/
case InputExhausted(data: String, length: Int) extends ProtocolError(s"Input exhausted. Length: $length")
/**
* Tried to decode an invalid input.
*/
case InvalidInput(input: String, message: String) extends ProtocolError(s"Invalid input: $input, $message")
/**
* The input is in invalid format.
*/
case InvalidFormat(message: String) extends ProtocolError(s"Invalid format: $message")
/**
* Miscellaneous error.
*/
case Miscellaneous(message: String) extends ProtocolError(message)
/**
* The ProtocolError has been caused by a thrown error.
*/
case Thrown(cause: Throwable) extends ProtocolError(cause.getMessage)
/**
* The connection has been closed.
*/
case ConnectionClosed extends ProtocolError("Connection closed")
/**
* The authentification process failed.
*/
case AuthentificationFailed(message: String) extends ProtocolError(s"Authentification failed: $message")
/**
* An aggregation of multiple errors.
*/
case Multiple(errors: List[ProtocolError]) extends ProtocolError(s"Errors: \n${errors.mkString("\n- ")}")