@@ -31,12 +31,12 @@ extension UInt8: PostgresDecodable {
3131 switch type {
3232 case . bpchar, . char:
3333 guard buffer. readableBytes == 1 , let value = buffer. readInteger ( as: UInt8 . self) else {
34- throw PostgresCastingError . Code. failure
34+ throw PostgresDecodingError . Code. failure
3535 }
3636
3737 self = value
3838 default :
39- throw PostgresCastingError . Code. typeMismatch
39+ throw PostgresDecodingError . Code. typeMismatch
4040 }
4141 }
4242}
@@ -74,16 +74,16 @@ extension Int16: PostgresDecodable {
7474 switch ( format, type) {
7575 case ( . binary, . int2) :
7676 guard buffer. readableBytes == 2 , let value = buffer. readInteger ( as: Int16 . self) else {
77- throw PostgresCastingError . Code. failure
77+ throw PostgresDecodingError . Code. failure
7878 }
7979 self = value
8080 case ( . text, . int2) :
8181 guard let string = buffer. readString ( length: buffer. readableBytes) , let value = Int16 ( string) else {
82- throw PostgresCastingError . Code. failure
82+ throw PostgresDecodingError . Code. failure
8383 }
8484 self = value
8585 default :
86- throw PostgresCastingError . Code. typeMismatch
86+ throw PostgresDecodingError . Code. typeMismatch
8787 }
8888 }
8989}
@@ -96,7 +96,7 @@ extension Int32: PostgresEncodable {
9696 public static var psqlType : PostgresDataType {
9797 . int4
9898 }
99-
99+
100100 public static var psqlFormat : PostgresFormat {
101101 . binary
102102 }
@@ -121,21 +121,21 @@ extension Int32: PostgresDecodable {
121121 switch ( format, type) {
122122 case ( . binary, . int2) :
123123 guard buffer. readableBytes == 2 , let value = buffer. readInteger ( as: Int16 . self) else {
124- throw PostgresCastingError . Code. failure
124+ throw PostgresDecodingError . Code. failure
125125 }
126126 self = Int32 ( value)
127127 case ( . binary, . int4) :
128128 guard buffer. readableBytes == 4 , let value = buffer. readInteger ( as: Int32 . self) else {
129- throw PostgresCastingError . Code. failure
129+ throw PostgresDecodingError . Code. failure
130130 }
131131 self = Int32 ( value)
132132 case ( . text, . int2) , ( . text, . int4) :
133133 guard let string = buffer. readString ( length: buffer. readableBytes) , let value = Int32 ( string) else {
134- throw PostgresCastingError . Code. failure
134+ throw PostgresDecodingError . Code. failure
135135 }
136136 self = value
137137 default :
138- throw PostgresCastingError . Code. typeMismatch
138+ throw PostgresDecodingError . Code. typeMismatch
139139 }
140140 }
141141}
@@ -173,26 +173,26 @@ extension Int64: PostgresDecodable {
173173 switch ( format, type) {
174174 case ( . binary, . int2) :
175175 guard buffer. readableBytes == 2 , let value = buffer. readInteger ( as: Int16 . self) else {
176- throw PostgresCastingError . Code. failure
176+ throw PostgresDecodingError . Code. failure
177177 }
178178 self = Int64 ( value)
179179 case ( . binary, . int4) :
180180 guard buffer. readableBytes == 4 , let value = buffer. readInteger ( as: Int32 . self) else {
181- throw PostgresCastingError . Code. failure
181+ throw PostgresDecodingError . Code. failure
182182 }
183183 self = Int64 ( value)
184184 case ( . binary, . int8) :
185185 guard buffer. readableBytes == 8 , let value = buffer. readInteger ( as: Int64 . self) else {
186- throw PostgresCastingError . Code. failure
186+ throw PostgresDecodingError . Code. failure
187187 }
188188 self = value
189189 case ( . text, . int2) , ( . text, . int4) , ( . text, . int8) :
190190 guard let string = buffer. readString ( length: buffer. readableBytes) , let value = Int64 ( string) else {
191- throw PostgresCastingError . Code. failure
191+ throw PostgresDecodingError . Code. failure
192192 }
193193 self = value
194194 default :
195- throw PostgresCastingError . Code. typeMismatch
195+ throw PostgresDecodingError . Code. typeMismatch
196196 }
197197 }
198198}
@@ -212,7 +212,7 @@ extension Int: PostgresEncodable {
212212 preconditionFailure ( " Int is expected to be an Int32 or Int64 " )
213213 }
214214 }
215-
215+
216216 public static var psqlFormat : PostgresFormat {
217217 . binary
218218 }
@@ -237,26 +237,26 @@ extension Int: PostgresDecodable {
237237 switch ( format, type) {
238238 case ( . binary, . int2) :
239239 guard buffer. readableBytes == 2 , let value = buffer. readInteger ( as: Int16 . self) else {
240- throw PostgresCastingError . Code. failure
240+ throw PostgresDecodingError . Code. failure
241241 }
242242 self = Int ( value)
243243 case ( . binary, . int4) :
244244 guard buffer. readableBytes == 4 , let value = buffer. readInteger ( as: Int32 . self) . flatMap ( { Int ( exactly: $0) } ) else {
245- throw PostgresCastingError . Code. failure
245+ throw PostgresDecodingError . Code. failure
246246 }
247247 self = value
248248 case ( . binary, . int8) :
249249 guard buffer. readableBytes == 8 , let value = buffer. readInteger ( as: Int . self) . flatMap ( { Int ( exactly: $0) } ) else {
250- throw PostgresCastingError . Code. failure
250+ throw PostgresDecodingError . Code. failure
251251 }
252252 self = value
253253 case ( . text, . int2) , ( . text, . int4) , ( . text, . int8) :
254254 guard let string = buffer. readString ( length: buffer. readableBytes) , let value = Int ( string) else {
255- throw PostgresCastingError . Code. failure
255+ throw PostgresDecodingError . Code. failure
256256 }
257257 self = value
258258 default :
259- throw PostgresCastingError . Code. typeMismatch
259+ throw PostgresDecodingError . Code. typeMismatch
260260 }
261261 }
262262}
0 commit comments