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

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

21 Nov 2023 11:42PM UTC coverage: 30.623% (-0.03%) from 30.652%
6951017262

Pull #792

CryptoKnightIOG
feat: Create Store Presentation (#788)

Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Pull Request #792: Feat: ZKP verification

25 of 126 new or added lines in 10 files covered. (19.84%)

315 existing lines in 107 files now uncovered.

4003 of 13072 relevant lines covered (30.62%)

0.31 hits per line

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

45.16
/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 sttp.model.StatusCode
5
import sttp.tapir.Schema
6
import sttp.tapir.Schema.annotations.{description, encodedExample}
7
import sttp.tapir.generic.auto.*
8
import sttp.tapir.json.zio.jsonBody
9
import sttp.tapir.server.model.ValuedEndpointOutput
10
import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder}
11

12
case class ErrorResponse(
×
13
    @description(annotations.status.description)
×
14
    @encodedExample(annotations.status.example)
15
    status: Int,
×
16
    @description(annotations.`type`.description)
1✔
17
    @encodedExample(annotations.`type`.example)
18
    `type`: String,
×
19
    @description(annotations.title.description)
×
20
    @encodedExample(annotations.title.example)
21
    title: String,
×
22
    @description(annotations.detail.description)
×
23
    @encodedExample(annotations.detail.example)
24
    detail: Option[String],
×
25
    @description(annotations.instance.description)
×
26
    @encodedExample(annotations.instance.example)
27
    instance: String
28
)
29

UNCOV
30
object ErrorResponse {
×
31
  given encoder: zio.json.JsonEncoder[ErrorResponse] = DeriveJsonEncoder.gen[ErrorResponse]
32

1✔
33
  given decoder: zio.json.JsonDecoder[ErrorResponse] = DeriveJsonDecoder.gen[ErrorResponse]
34

×
35
  given schema: Schema[ErrorResponse] = Schema.derived
36

1✔
37
  def failureResponseHandler(msg: String): ValuedEndpointOutput[_] =
1✔
38
    ValuedEndpointOutput(jsonBody[ErrorResponse], ErrorResponse.badRequest(detail = Option(msg)))
39

40
  object annotations {
41
    object status
1✔
42
        extends Annotation[Int](
43
          description = "The HTTP status code for this occurrence of the problem.",
44
          example = 200
45
        )
46
    object `type`
1✔
47
        extends Annotation[String](
48
          description = "A URI reference that identifies the problem type.",
49
          example = "https://example.org/doc/#model-MalformedEmail/"
50
        )
51

52
    object title
1✔
53
        extends Annotation[String](
54
          description =
1✔
55
            "A short, human-readable summary of the problem type. It does not change from occurrence to occurrence of the problem.",
56
          example = "Malformed email"
57
        )
58

59
    object detail
1✔
60
        extends Annotation[Option[String]](
61
          description = "A human-readable explanation specific to this occurrence of the problem.",
1✔
62
          example = Option("The received '{}à!è@!.b}' email does not conform to the email format")
63
        )
64

65
    object instance
×
66
        extends Annotation[String](
67
          description =
68
            "A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.",
1✔
69
          example = "The received '{}à!è@!.b}' email does not conform to the email format"
70
        )
71
  }
72

1✔
73
  def notFound(title: String = "NotFound", detail: Option[String] = None, instance: String = "") =
74
    ErrorResponse(StatusCode.NotFound.code, `type` = "NotFound", title = title, detail = detail, instance = instance)
UNCOV
75

×
76
  def internalServerError(title: String = "InternalServerError", detail: Option[String] = None, instance: String = "") =
77
    ErrorResponse(
×
78
      StatusCode.InternalServerError.code,
79
      `type` = "InternalServerError",
80
      title = title,
81
      detail = detail,
82
      instance = instance
83
    )
84

1✔
85
  def badRequest(title: String = "BadRequest", detail: Option[String] = None, instance: String = "") =
86
    ErrorResponse(
87
      StatusCode.BadRequest.code,
88
      `type` = title,
89
      title = title,
90
      detail = detail,
91
      instance = instance
92
    )
93

×
94
  def unprocessableEntity(title: String = "UnprocessableEntity", detail: Option[String] = None, instance: String = "") =
95
    ErrorResponse(
96
      StatusCode.UnprocessableEntity.code,
97
      `type` = title,
98
      title = title,
99
      detail = detail,
100
      instance = instance
101
    )
102

×
103
  def conflict(title: String = "Conflict", detail: Option[String] = None, instance: String = "") =
104
    ErrorResponse(
105
      StatusCode.Conflict.code,
106
      `type` = title,
107
      title = title,
108
      detail = detail,
×
109
      instance = instance
110
    )
111
}
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