Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ coverage:
status:
patch:
default:
target: auto
target: 49
changes: false
project:
default:
Expand Down
4 changes: 2 additions & 2 deletions Sources/ParseSwift/API/URLSession+extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension URLSession {
mapper: @escaping (Data) throws -> U) -> Result<U, ParseError> {
if let responseError = responseError {
guard let parseError = responseError as? ParseError else {
return .failure(ParseError(code: .invalidServerResponse,
return .failure(ParseError(code: .unknownError,
message: "Unable to sync with parse-server: \(responseError)"))
}
return .failure(parseError)
Expand Down Expand Up @@ -69,7 +69,7 @@ extension URLSession {
mapper: @escaping (Data) throws -> U) -> Result<U, ParseError> {
if let responseError = responseError {
guard let parseError = responseError as? ParseError else {
return .failure(ParseError(code: .invalidServerResponse,
return .failure(ParseError(code: .unknownError,
message: "Unable to sync with parse-server: \(responseError)"))
}
return .failure(parseError)
Expand Down
131 changes: 100 additions & 31 deletions Sources/ParseSwift/Types/ParseError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public struct ParseError: ParseType, Decodable, Swift.Error {
as `code` for `Error` for callbacks on all classes.
*/
public enum Code: Int, Swift.Error, Codable {

/**
Internal SDK Error. No information available
*/
Expand All @@ -35,191 +36,248 @@ public struct ParseError: ParseType, Decodable, Swift.Error {
Internal server error. No information available.
*/
case internalServer = 1

/**
The connection to the Parse servers failed.
*/
case connectionFailed = 100

/**
Object doesn't exist, or has an incorrect password.
*/
case objectNotFound = 101

/**
You tried to find values matching a datatype that doesn't
support exact database matching, like an array or a dictionary.
*/
case invalidQuery = 102

/**
Missing or invalid classname. Classnames are case-sensitive.
They must start with a letter, and `a-zA-Z0-9_` are the only valid characters.
*/
case invalidClassName = 103

/**
Missing object id.
*/
case missingObjectId = 104

/**
Invalid key name. Keys are case-sensitive.
They must start with a letter, and `a-zA-Z0-9_` are the only valid characters.
*/
case invalidKeyName = 105

/**
Malformed pointer. Pointers must be arrays of a classname and an object id.
*/
case invalidPointer = 106

/**
Malformed json object. A json dictionary is expected.
*/
case invalidJSON = 107

/**
Tried to access a feature only available internally.
*/
case commandUnavailable = 108

/**
Field set to incorrect type.
*/
case incorrectType = 111

/**
Invalid channel name. A channel name is either an empty string (the broadcast channel)
or contains only `a-zA-Z0-9_` characters and starts with a letter.
*/
case invalidChannelName = 112

/**
Invalid device token.
*/
case invalidDeviceToken = 114

/**
Push is misconfigured. See details to find out how.
*/
case pushMisconfigured = 115

/**
The object is too large.
*/
case objectTooLarge = 116

/**
That operation isn't allowed for clients.
*/
case operationForbidden = 119

/**
The results were not found in the cache.
*/
case cacheMiss = 120

/**
Keys in `NSDictionary` values may not include `$` or `.`.
*/
case invalidNestedKey = 121

/**
Invalid file name.
A file name can contain only `a-zA-Z0-9_.` characters and should be between 1 and 36 characters.
*/
case invalidFileName = 122

/**
Invalid ACL. An ACL with an invalid format was saved. This should not happen if you use `ACL`.
*/
case invalidACL = 123

/**
The request timed out on the server. Typically this indicates the request is too expensive.
*/
case timeout = 124

/**
The email address was invalid.
*/
case invalidEmailAddress = 125

/**
A unique field was given a value that is already taken.
*/
case duplicateValue = 137
/**
Role's name is invalid.
Missing content type.
*/
case invalidRoleName = 139
case missingContentType = 126

/**
Exceeded an application quota. Upgrade to resolve.
Missing content length.
*/
case exceededQuota = 140
case missingContentLength = 127

/**
Cloud Code script had an error.
Invalid content length.
*/
case scriptError = 141
case invalidContentLength = 128

/**
Cloud Code validation failed.
File was too large.
*/
case validationError = 142
case fileTooLarge = 129

/**
Product purchase receipt is missing.
Failure saving a file.
*/
case receiptMissing = 143
case fileSaveFailure = 130

/**
Product purchase receipt is invalid.
A unique field was given a value that is already taken.
*/
case invalidPurchaseReceipt = 144
case duplicateValue = 137

/**
Payment is disabled on this device.
Role's name is invalid.
*/
case paymentDisabled = 145
case invalidRoleName = 139

/**
The product identifier is invalid.
Exceeded an application quota. Upgrade to resolve.
*/
case invalidProductIdentifier = 146
case exceededQuota = 140

/**
The product is not found in the App Store.
Cloud Code script had an error.
*/
case productNotFoundInAppStore = 147
case scriptFailed = 141

/**
The Apple server response is not valid.
Cloud Code validation failed.
*/
case invalidServerResponse = 148
case validationFailed = 142

/**
Product fails to download due to file system error.
Fail to convert data to image.
*/
case productDownloadFileSystemFailure = 149
case invalidImageData = 143

/**
Fail to convert data to image.
Unsaved file failure.
*/
case invalidImageData = 150
case unsavedFileFailure = 151

/**
Unsaved file.
An invalid push time.
*/
case unsavedFile = 151
case invalidPushTime = 152

/**
Fail to delete file.
*/
case fileDeleteFailure = 153

/**
Fail to delete an unnamed file.
*/
case fileDeleteUnnamedFailure = 161

/**
Application has exceeded its request limit.
*/
case requestLimitExceeded = 155

/**
The request was a duplicate and has been discarded
due to idempotency rules.
*/
case duplicateRequest = 159

/**
Invalid event name.
*/
case invalidEventName = 160

/**
Invalid value.
*/
case invalidValue = 162

/**
Username is missing or empty.
*/
case usernameMissing = 200

/**
Password is missing or empty.
*/
case userPasswordMissing = 201

/**
Username has already been taken.
*/
case usernameTaken = 202

/**
Email has already been taken.
*/
case userEmailTaken = 203

/**
The email is missing, and must be specified.
*/
case userEmailMissing = 204

/**
A user with the specified email was not found.
*/
case userWithEmailNotFound = 205

/**
The user cannot be altered by a client without the session.
*/
case userCannotBeAlteredWithoutSession = 206

/**
Users can only be created through sign up.
*/
Expand All @@ -229,11 +287,22 @@ public struct ParseError: ParseType, Decodable, Swift.Error {
An existing account already linked to another user.
*/
case accountAlreadyLinked = 208

/**
Error code indicating that the current session token is invalid.
The current session token is invalid.
*/
case invalidSessionToken = 209

/**
Error enabling or verifying MFA.
*/
case mfaError = 210

/**
A valid MFA token must be provided.
*/
case mfaTokenRequired = 211

/**
Linked id missing from request.
*/
Expand Down
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/APICommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class APICommandTests: XCTestCase {

//This is less common as the HTTP won't be able to produce ParseErrors directly, but used for testing
func testErrorHTTPReturnsParseError1() {
let originalError = ParseError(code: .invalidServerResponse, message: "Couldn't decode")
let originalError = ParseError(code: .unknownError, message: "Couldn't decode")
MockURLProtocol.mockRequests { _ in
return MockURLResponse(error: originalError)
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/ParseSwiftTests/ParseCloudTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class ParseCloudTests: XCTestCase { // swiftlint:disable:this type_body_length

func testFunctionError() {

let parseError = ParseError(code: .scriptError, message: "Error: Invalid function")
let parseError = ParseError(code: .scriptFailed, message: "Error: Invalid function")

let encoded: Data!
do {
Expand Down Expand Up @@ -245,7 +245,7 @@ class ParseCloudTests: XCTestCase { // swiftlint:disable:this type_body_length
}

func testFunctionMainQueueError() {
let parseError = ParseError(code: .scriptError, message: "Error: Invalid function")
let parseError = ParseError(code: .scriptFailed, message: "Error: Invalid function")

MockURLProtocol.mockRequests { _ in
do {
Expand Down Expand Up @@ -322,7 +322,7 @@ class ParseCloudTests: XCTestCase { // swiftlint:disable:this type_body_length

func testJobError() {

let parseError = ParseError(code: .scriptError, message: "Error: Invalid function")
let parseError = ParseError(code: .scriptFailed, message: "Error: Invalid function")

let encoded: Data!
do {
Expand Down Expand Up @@ -402,7 +402,7 @@ class ParseCloudTests: XCTestCase { // swiftlint:disable:this type_body_length
}

func testJobMainQueueError() {
let parseError = ParseError(code: .scriptError, message: "Error: Invalid function")
let parseError = ParseError(code: .scriptFailed, message: "Error: Invalid function")

MockURLProtocol.mockRequests { _ in
do {
Expand Down