All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.scalameta.UnreachableError.scala Maven / Gradle / Ivy

package org.scalameta

import org.scalameta.internal.ScalaCompat.EOL

class UnreachableError(message: String) extends Error(message)

object UnreachableError {
  def raise(debuggees: Map[String, Any]): Nothing = raise(debuggees, null)

  def raise(debuggees: Map[String, Any], clue: String): Nothing = {
    val mandatory = "this code path should've been unreachable"
    throw new UnreachableError(
      if (debuggees.isEmpty && clue == null) mandatory
      else {
        val sb = new StringBuilder()
        sb.append(mandatory)
        if (clue ne null) sb.append(" (").append(clue).append(')')
        sb.append(EOL)
        ExceptionHelpers.formatDebuggees(sb, debuggees)
        sb.result()
      }
    )
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy