• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / atala-prism-building-blocks / 8722405814

17 Apr 2024 01:02PM UTC coverage: 31.005% (-0.6%) from 31.633%
8722405814

Pull #966

patlo-iog
chore: resolve conflict

Signed-off-by: Pat Losoponkul <pat.losoponkul@iohk.io>
Pull Request #966: feat: key management for Ed25519 and X25519

109 of 386 new or added lines in 22 files covered. (28.24%)

386 existing lines in 101 files now uncovered.

4478 of 14443 relevant lines covered (31.0%)

0.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.86
/prism-agent/service/server/src/main/scala/io/iohk/atala/api/http/ErrorResponse.scala
1
package io.iohk.atala.api.http
2

3
import io.iohk.atala.api.http.ErrorResponse.annotations
4
import io.iohk.atala.shared.models.Failure
5
import sttp.model.StatusCode
6
import sttp.tapir.Schema
7
import sttp.tapir.Schema.annotations.{description, encodedExample}
8
import sttp.tapir.generic.auto.*
9
import zio.ZIO
10
import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder}
11

12
import java.util.UUID
13
import scala.util.matching.Regex
14

15
private val INSTANCE_URI_PREFIX = "error:instance:"
16

17
case class ErrorResponse(
×
18
    @description(annotations.status.description)
1✔
19
    @encodedExample(annotations.status.example)
20
    status: Int,
×
21
    @description(annotations.`type`.description)
×
22
    @encodedExample(annotations.`type`.example)
23
    `type`: String,
×
24
    @description(annotations.title.description)
×
25
    @encodedExample(annotations.title.example)
26
    title: String,
×
27
    @description(annotations.detail.description)
×
28
    @encodedExample(annotations.detail.example)
×
29
    detail: Option[String] = None,
×
30
    @description(annotations.instance.description)
×
31
    @encodedExample(annotations.instance.example)
1✔
32
    instance: String = INSTANCE_URI_PREFIX + UUID.randomUUID().toString
33
)
34

35
object ErrorResponse {
1✔
36
  given encoder: zio.json.JsonEncoder[ErrorResponse] = DeriveJsonEncoder.gen[ErrorResponse]
37

1✔
38
  given decoder: zio.json.JsonDecoder[ErrorResponse] = DeriveJsonDecoder.gen[ErrorResponse]
39

×
40
  given schema: Schema[ErrorResponse] = Schema.derived
41

1✔
42
  private val CamelCaseSplitRegex: Regex = "(([A-Z]?[a-z]+)|([A-Z]))".r
×
43
  given failureToErrorResponseConversion[R, A]: Conversion[ZIO[R, Failure, A], ZIO[R, ErrorResponse, A]] = { effect =>
×
44
    effect.mapError { failure =>
×
45
      val simpleName = failure.getClass.getSimpleName
×
46
      ErrorResponse(
47
        failure.statusCode.code,
×
48
        s"error:ConnectionServiceError:$simpleName",
×
49
        CamelCaseSplitRegex.findAllIn(simpleName).mkString(" "),
1✔
50
        Some(failure.userFacingMessage)
51
      )
52
    }
53
  }
54

55
  object annotations {
56
    object status
1✔
57
        extends Annotation[Int](
58
          description = "The HTTP status code for this occurrence of the problem.",
59
          example = 200
60
        )
61
    object `type`
1✔
62
        extends Annotation[String](
63
          description = "A URI reference that identifies the problem type.",
64
          example = "https://example.org/doc/#model-MalformedEmail/"
65
        )
66

67
    object title
1✔
68
        extends Annotation[String](
69
          description =
×
70
            "A short, human-readable summary of the problem type. It does not change from occurrence to occurrence of the problem.",
71
          example = "Malformed email"
72
        )
73

74
    object detail
1✔
75
        extends Annotation[Option[String]](
76
          description = "A human-readable explanation specific to this occurrence of the problem.",
1✔
77
          example = Option("The received '{}à!è@!.b}' email does not conform to the email format")
78
        )
79

80
    object instance
1✔
81
        extends Annotation[String](
82
          description =
83
            "A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.",
×
84
          example = "The received '{}à!è@!.b}' email does not conform to the email format"
85
        )
86
  }
87

1✔
88
  def notFound(title: String = "NotFound", detail: Option[String] = None) =
1✔
89
    ErrorResponse(StatusCode.NotFound.code, `type` = "NotFound", title = title, detail = detail)
UNCOV
90

×
91
  def internalServerError(title: String = "InternalServerError", detail: Option[String] = None) =
1✔
92
    ErrorResponse(
93
      StatusCode.InternalServerError.code,
94
      `type` = "InternalServerError",
95
      title = title,
96
      detail = detail
97
    )
98

1✔
99
  def badRequest(title: String = "BadRequest", detail: Option[String] = None) =
1✔
100
    ErrorResponse(
101
      StatusCode.BadRequest.code,
102
      `type` = title,
103
      title = title,
104
      detail = detail
105
    )
106

×
107
  def unprocessableEntity(title: String = "UnprocessableEntity", detail: Option[String] = None) =
×
108
    ErrorResponse(
109
      StatusCode.UnprocessableEntity.code,
×
110
      `type` = title,
111
      title = title,
112
      detail = detail
113
    )
114

×
115
  def conflict(title: String = "Conflict", detail: Option[String] = None) =
×
116
    ErrorResponse(
117
      StatusCode.Conflict.code,
118
      `type` = title,
119
      title = title,
120
      detail = detail
121
    )
122
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc