Skip to content

Commit 13bb77c

Browse files
fix: Removes execution fatalErrors
1 parent 6faf27d commit 13bb77c

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Sources/GraphQL/Execution/Execute.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ func completeValueCatchingError(
796796
result: result
797797
).flatMapError { error -> EventLoopFuture<Any?> in
798798
guard let error = error as? GraphQLError else {
799-
fatalError()
799+
return exeContext.eventLoopGroup.next().makeFailedFuture(error)
800800
}
801801
exeContext.append(error: error)
802802
return exeContext.eventLoopGroup.next().makeSucceededFuture(nil)
@@ -809,7 +809,7 @@ func completeValueCatchingError(
809809
exeContext.append(error: error)
810810
return exeContext.eventLoopGroup.next().makeSucceededFuture(nil)
811811
} catch {
812-
fatalError()
812+
return exeContext.eventLoopGroup.next().makeFailedFuture(error)
813813
}
814814
}
815815

Sources/GraphQL/Map/Map.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,13 @@ extension Map : Codable {
663663

664664
switch self {
665665
case .undefined:
666-
fatalError("undefined values should have been excluded from encoding")
666+
throw EncodingError.invalidValue(
667+
self,
668+
EncodingError.Context(
669+
codingPath: [],
670+
debugDescription: "undefined values should have been excluded from encoding"
671+
)
672+
)
667673
case .null:
668674
try container.encodeNil()
669675
case let .bool(value):

Sources/GraphQL/Map/MapSerialization.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ public struct MapSerialization {
3535
static func object(with map: Map) throws -> NSObject {
3636
switch map {
3737
case .undefined:
38-
fatalError("undefined values should have been excluded from serialization")
38+
throw EncodingError.invalidValue(
39+
self,
40+
EncodingError.Context(
41+
codingPath: [],
42+
debugDescription: "undefined values should have been excluded from serialization"
43+
)
44+
)
3945
case .null:
4046
return NSNull()
4147
case let .bool(value):

0 commit comments

Comments
 (0)