Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorCodeDocumentationGenerator uses multiple prefixes for scanning classpaths #11504

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ object ErrorGroups {

private implicit val errorClass: ErrorClass = ErrorClass.root()

abstract class ProtoDeserializationErrorGroup extends ErrorGroup

object ParticipantErrorGroup extends ErrorGroup() {
abstract class IndexErrorGroup extends ErrorGroup() {
abstract class DatabaseErrorGroup extends ErrorGroup()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import scala.jdk.CollectionConverters._
*
* @param prefix The classpath prefix that should be scanned for finding subtypes of [[ErrorCode]].
*/
case class ErrorCodeDocumentationGenerator(prefix: String = "com.daml") {
class ErrorCodeDocumentationGenerator(prefixes: Array[String] = Array("com.daml")) {

def getDocItems: Seq[DocItem] = {
val errorCodes = getErrorCodeInstances
Expand All @@ -40,7 +40,7 @@ case class ErrorCodeDocumentationGenerator(prefix: String = "com.daml") {
}

private def getErrorCodeInstances: Seq[ErrorCode] =
new Reflections(prefix)
new Reflections(prefixes)
.getSubTypesOf(classOf[ErrorCode])
.asScala
.view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object Main {
Encoder.forProduct1("errorCodes")(i => (i.errorCodes))

def main(args: Array[String]): Unit = {
val errorCodes = ErrorCodeDocumentationGenerator().getDocItems
val errorCodes = new ErrorCodeDocumentationGenerator().getDocItems
val outputFile = Paths.get(args(0))
val output = Output(errorCodes)
val outputText: String = output.asJson.spaces2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class ErrorCodeDocumentationGeneratorSpec extends AnyFlatSpec with Matchers {
private val className = ErrorCodeDocumentationGenerator.getClass.getSimpleName

// Scan errors from the utils test package
private val generator = ErrorCodeDocumentationGenerator("com.daml.error.utils.testpackage")
private val generator = new ErrorCodeDocumentationGenerator(
Array("com.daml.error.utils.testpackage")
)

s"$className.getDocItems" should "return the correct doc items from the error classes" in {
val actualDocItems = generator.getDocItems
Expand Down