Skip to content

Commit

Permalink
Action sbt scalafmtAll
Browse files Browse the repository at this point in the history
  • Loading branch information
takapi327 committed Jan 1, 2025
1 parent 75a6b1c commit 29ba453
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ package ldbc.dsl.exception
*/
class DecodeFailureException(
message: String,
offset: Int
offset: Int
) extends LdbcException(
message,
Some(s"An attempt to read a value from the ${offset}th position of the ResultSet failed due to an error."),
Some(
"""
message,
Some(s"An attempt to read a value from the ${ offset }th position of the ResultSet failed due to an error."),
Some("""
| The number of records retrieved from MySQL may not match the number of Decoders.
| Try building a Decoder that matches the number and type of cases to be acquired as follows.
|
| given Decoder[(Int, String)] = Decoder[Int] *: Decoder[String]
| sql"SELECT c1, c2 FROM table".query[(Int, String)]
|""".stripMargin)
):
):

override def title: String = "Decode Failure Exception"
override protected def width = 180
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import cats.syntax.all.*
* The superclass of all exceptions thrown by the ldbc DSL.
*/
class LdbcException(
message: String,
detail: Option[String] = None,
hint: Option[String] = None,
) extends Exception:
message: String,
detail: Option[String] = None,
hint: Option[String] = None
) extends Exception:

def title: String = "ldbc Exception"

Expand All @@ -34,22 +34,25 @@ class LdbcException(
else
"\n|" +
label + Console.CYAN + wrap(
width - label.length,
s,
s"${Console.RESET}\n${Console.CYAN}" + label.map(_ => ' ')
) + Console.RESET
width - label.length,
s,
s"${ Console.RESET }\n${ Console.CYAN }" + label.map(_ => ' ')
) + Console.RESET

protected def header: String = title

protected def body: String =
s"""
|${ labeled(" Problem: ", message) }${ labeled(" Detail: ", detail.orEmpty) }${ labeled(" Hint: ", hint.orEmpty) }
|${ labeled(" Problem: ", message) }${ labeled(" Detail: ", detail.orEmpty) }${ labeled(
" Hint: ",
hint.orEmpty
) }
|""".stripMargin

protected def sections: List[String] =
List(header, body)

final override def getMessage: String =
sections.combineAll.linesIterator
.map("🔥 " + _)
.mkString("\n", "\n", s"\n\n${getClass.getName}: $message")
.mkString("\n", "\n", s"\n\n${ getClass.getName }: $message")

0 comments on commit 29ba453

Please sign in to comment.