Skip to content

Commit 7d2f821

Browse files
authored
Improve encode/decode error messages (#287)
* fix ci * fix ci * improve encoding error messages
1 parent ca482ca commit 7d2f821

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Sources/MySQLKit/MySQLDataDecoder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public struct MySQLDataDecoder {
3838
guard let value = convertible.init(mysqlData: data) else {
3939
throw DecodingError.typeMismatch(T.self, DecodingError.Context(
4040
codingPath: [],
41-
debugDescription: "Could not convert to \(T.self): \(data)",
41+
debugDescription: "Could not convert MySQL data to \(T.self): \(data)",
4242
underlyingError: nil
4343
))
4444
}
@@ -102,7 +102,7 @@ public struct MySQLDataDecoder {
102102
guard let value = convertible.init(mysqlData: self.decoder.data) else {
103103
throw DecodingError.typeMismatch(T.self, DecodingError.Context.init(
104104
codingPath: self.codingPath,
105-
debugDescription: "Could not convert from MySQL data: \(T.self)"
105+
debugDescription: "Could not convert MySQL data to \(T.self): \(self.decoder.data)"
106106
))
107107
}
108108
return value as! T

Sources/MySQLKit/MySQLDataEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public struct MySQLDataEncoder {
149149
guard let data = convertible.mysqlData else {
150150
throw EncodingError.invalidValue(convertible, EncodingError.Context(
151151
codingPath: self.codingPath,
152-
debugDescription: "Could not convert value of type \(T.self)"
152+
debugDescription: "Could not encode \(T.self) to MySQL data: \(value)"
153153
))
154154
}
155155
self.encoder.data = data

0 commit comments

Comments
 (0)