-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iss #24: universal config: append usage, extract result types
- Loading branch information
Showing
9 changed files
with
230 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core/src/main/scala/ru/maizy/ambient7/core/config/ParsingError.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ru.maizy.ambient7.core.config | ||
|
||
/** | ||
* Copyright (c) Nikita Kovaliov, maizy.ru, 2016 | ||
* See LICENSE.txt for details. | ||
*/ | ||
|
||
case class ParsingError(messages: IndexedSeq[String] = IndexedSeq.empty, usage: Option[String] = None) { | ||
def merge(other: ParsingError): ParsingError = { | ||
val mergedUsage = (usage, other.usage) match { | ||
case (Some(text), Some(otherText)) => Some(text + "\n" + otherText) | ||
case (None, otherUsage@Some(_)) => otherUsage | ||
case (thisUsage@Some(_), None) => thisUsage | ||
case _ => None | ||
} | ||
copy(messages ++ other.messages, mergedUsage) | ||
} | ||
|
||
def appendUsage(additionalUsage: String): ParsingError = | ||
copy(usage = Some(Seq(usage.getOrElse(""), additionalUsage).mkString("\n"))) | ||
} | ||
|
||
object ParsingError { | ||
def merge(a: ParsingError, b: ParsingError): ParsingError = a merge b | ||
|
||
def withMessage(message: String): ParsingError = | ||
ParsingError(IndexedSeq(message)) | ||
|
||
def withMessages(messages: String*): ParsingError = | ||
ParsingError(messages.toIndexedSeq) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
core/src/main/scala/ru/maizy/ambient7/core/config/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package ru.maizy.ambient7.core | ||
|
||
import com.typesafe.scalalogging.{ LazyLogging, Logger } | ||
|
||
/** | ||
* Copyright (c) Nikita Kovaliov, maizy.ru, 2016 | ||
* See LICENSE.txt for details. | ||
*/ | ||
|
||
import com.typesafe.scalalogging.{ LazyLogging, Logger } | ||
|
||
package object config extends LazyLogging { | ||
val configLogger: Logger = logger | ||
} |
Oops, something went wrong.