Skip to content

Commit 7aba8ef

Browse files
markgravitysuho
authored andcommitted
[#8] Add public constructors
1 parent a8c1349 commit 7aba8ef

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Sources/JSONAPIMapper/Models/JSONAPIError.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ public struct JSONAPIError: Error, Decodable, Equatable {
1010

1111
public struct Source: Decodable, Equatable {
1212
public let parameter: String?
13+
14+
public init(parameter: String? = nil) {
15+
self.parameter = parameter
16+
}
1317
}
1418

1519
public let id: String?
@@ -20,6 +24,22 @@ public struct JSONAPIError: Error, Decodable, Equatable {
2024
public let status: String?
2125
/// application-specific error code
2226
public let code: String?
27+
28+
public init(
29+
id: String? = nil,
30+
title: String? = nil,
31+
detail: String? = nil,
32+
source: Source,
33+
status: String? = nil,
34+
code: String? = nil
35+
) {
36+
self.id = id
37+
self.title = title
38+
self.detail = detail
39+
self.source = source
40+
self.status = status
41+
self.code = code
42+
}
2343
}
2444

2545
/// JSON:API error object is sent as an array of errors.

0 commit comments

Comments
 (0)