Skip to content

Commit

Permalink
Improved error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
tijme committed Sep 5, 2021
1 parent a217c2e commit b7244d6
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .semver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.0
1.2.2
8 changes: 4 additions & 4 deletions Raivo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1579,15 +1579,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Raivo/Raivo.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 51;
CURRENT_PROJECT_VERSION = 52;
DEVELOPMENT_TEAM = 564B4ETY69;
INFOPLIST_FILE = "$(SRCROOT)/Raivo/Supporting/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.1;
MARKETING_VERSION = 1.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.finnwea.Raivo.Debug;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -1603,15 +1603,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Raivo/Raivo.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 51;
CURRENT_PROJECT_VERSION = 52;
DEVELOPMENT_TEAM = 564B4ETY69;
INFOPLIST_FILE = "$(SRCROOT)/Raivo/Supporting/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.1;
MARKETING_VERSION = 1.2.2;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
15 changes: 6 additions & 9 deletions Raivo/Errors/CryptographyError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,14 @@ public enum CryptographyError: LocalizedError {
public var errorDescription: String? {
switch self {
case .derivationFailed(let message):
log.error("Exception occurred")
log.error(message)
return id(self) + " - Derivation error. " + message
log.error(id(self) + " - Derivation error. " + message)
return message
case .encryptionFailed(let message):
log.error("Exception occurred")
log.error(message)
return id(self) + " - Encryption error. " + message
log.error(id(self) + " - Encryption error. " + message)
return message
case .decryptionFailed(let message):
log.error("Exception occurred")
log.error(message)
return id(self) + " - Decryption error. " + message
log.error(id(self) + " - Decryption error. " + message)
return message
}
}

Expand Down
4 changes: 2 additions & 2 deletions Raivo/Errors/RealmError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public enum RealmError: LocalizedError {
public var errorDescription: String? {
switch self {
case .unknownError:
log.error("Exception occurred")
log.error(id(self) + " - Unknown Error. " + "An unknown Realm Objective-C exception occurred")
return "An unknown Realm Objective-C exception occurred"
case .encryptionError:
log.error("Encryption error occurred")
log.error(id(self) + " - Encryption Error. " + "A Realm Objective-C invalid encryption key exception occurred")
return "A Realm Objective-C invalid encryption key exception occurred"
}
}
Expand Down
5 changes: 2 additions & 3 deletions Raivo/Errors/UnexpectedError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ public enum UnexpectedError: LocalizedError {
public var errorDescription: String? {
switch self {
case .vitalFunctionalityIsStub:
log.error("Exception occurred")
log.error(id(self) + " - VitalFunctionalityIsStub. " + "A vital method was executed, but it turned out to be a stub method")
return "A vital method was executed, but it turned out to be a stub method"
case .noErrorButNotSuccessful(let message):
log.error("Exception occurred")
log.error(message)
log.error(id(self) + " - NoErrorButNotSuccessful. " + message)
return message
}
}
Expand Down
5 changes: 2 additions & 3 deletions Raivo/Errors/ValidationError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ public enum ValidationError: LocalizedError {
public var errorDescription: String? {
switch self {
case .invalidFormat(let message):
log.error("Exception occurred")
log.error(message)
return id(self) + " - Validation error. " + message
log.error(id(self) + " - Invalid format. " + message)
return message
}
}

Expand Down
4 changes: 2 additions & 2 deletions Raivo/Helpers/ReceiverHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class ReceiverHelper {
}

guard let password = uri.queryItems?.first(where: { $0.name == "password" })?.value else {
throw ValidationError.invalidFormat("QR-code does not contain a valid password")
throw ValidationError.invalidFormat("QR-code does not contain a valid password.")
}

guard let name = uri.queryItems?.first(where: { $0.name == "name" })?.value else {
throw ValidationError.invalidFormat("QR-code does not contain a valid name")
throw ValidationError.invalidFormat("QR-code does not contain a valid name.")
}

let pushToken = String(uri.path.dropFirst())
Expand Down
5 changes: 3 additions & 2 deletions Raivo/Views/SwiftUI/MainReceiversView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ struct MainReceiversView: View {

do {
receiver = try ReceiverHelper.shared.getReceiverFromQRCode(qrcode: code)
} catch {
return BannerHelper.shared.done("Error", "The QR-code does not appear to be from a MacOS Receiver.", duration: 3.0)
} catch let error {
log.error(error.localizedDescription)
return BannerHelper.shared.done("Error", error.localizedDescription, duration: 3.0)
}

autoreleasepool {
Expand Down

0 comments on commit b7244d6

Please sign in to comment.