Skip to content

Commit

Permalink
ErrorCodeDocumentationGenerator uses multiple prefixes for scanning c…
Browse files Browse the repository at this point in the history
…lasspaths

* Removed ProtoDeserializationErrors (not needed at the moment)

CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
tudor-da committed Nov 2, 2021
1 parent 55d35e5 commit cd0b7cd
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 67 deletions.
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,7 @@ 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("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

0 comments on commit cd0b7cd

Please sign in to comment.