You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe the function decodeBody has an error, but I'm not sure.
The function:
public func decodeBody<Body: Codable>(_ type: Body.Type) throws -> Body? {
guard case let .data(bodyData, format)? = body else { return nil }
switch format {
case .json: return try JSONDecoder().decode(type, from: bodyData)
default: throw UnsupportedBodyFormatError(format)
}
}
should not be using .data but I think .codable.
The following code shows what I'm trying to do:
if let iapError = error as? IapStatusCode
{
if iapError.rawValue != IapStatusCode.maliformed.rawValue
{
XCTFail("The wrong error type was returned")
}
print("Not a valid receipt Apple Says: (iapError.errString)")
let theErr = RequestError(rawValue: 204, reason: iapError.errString)
let returnError = RequestError(theErr, body: iapError)
HERE:::: I'm calling REquestError with iapError of type IapStatusCode. This works as expected
let theIAPStatusCode = returnError.bodyAs(IapStatusCode.self)
HEEr::: theIAPStatusCode returns nil because of the: [guard case let .data(bodyData, format)? = body else { return nil }] I think it should be .codable
if theIAPStatusCode != IapStatusCode.maliformed
{
XCTFail("Return Error Incorrect")
}
}
The text was updated successfully, but these errors were encountered:
I believe the function decodeBody has an error, but I'm not sure.
The function:
public func decodeBody<Body: Codable>(_ type: Body.Type) throws -> Body? {
guard case let .data(bodyData, format)? = body else { return nil }
switch format {
case .json: return try JSONDecoder().decode(type, from: bodyData)
default: throw UnsupportedBodyFormatError(format)
}
}
should not be using .data but I think .codable.
The following code shows what I'm trying to do:
if let iapError = error as? IapStatusCode
{
if iapError.rawValue != IapStatusCode.maliformed.rawValue
{
XCTFail("The wrong error type was returned")
}
print("Not a valid receipt Apple Says: (iapError.errString)")
let theErr = RequestError(rawValue: 204, reason: iapError.errString)
let returnError = RequestError(theErr, body: iapError)
HERE:::: I'm calling REquestError with iapError of type IapStatusCode. This works as expected
HEEr::: theIAPStatusCode returns nil because of the: [guard case let .data(bodyData, format)? = body else { return nil }] I think it should be .codable
}
The text was updated successfully, but these errors were encountered: