Stuff…
This commit is contained in:
6
TagTunes/DescriptiveError.swift
Normal file → Executable file
6
TagTunes/DescriptiveError.swift
Normal file → Executable file
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
/// A custom error class that wraps another error to display a more descriptive
|
||||
/// error description than for example "The operation couldn't be completed."
|
||||
/// error description than for example "The operation couldn't be completed".
|
||||
public class DescriptiveError: NSError {
|
||||
|
||||
/// Initializes the receiver with the specified `underlyingError`.
|
||||
@@ -34,6 +34,8 @@ public class DescriptiveError: NSError {
|
||||
override public var localizedDescription: String {
|
||||
if domain == NSURLErrorDomain {
|
||||
switch code {
|
||||
case NSURLErrorCannotConnectToHost:
|
||||
fallthrough
|
||||
case NSURLErrorNotConnectedToInternet:
|
||||
return NSLocalizedString("You are not connected to the internet.", comment: "Error message informing the user that he is not connected to the internet.")
|
||||
case NSURLErrorTimedOut:
|
||||
@@ -47,6 +49,8 @@ public class DescriptiveError: NSError {
|
||||
override public var localizedRecoverySuggestion: String? {
|
||||
if domain == NSURLErrorDomain {
|
||||
switch code {
|
||||
case NSURLErrorCannotConnectToHost:
|
||||
fallthrough
|
||||
case NSURLErrorNotConnectedToInternet:
|
||||
return NSLocalizedString("Please check your network connection and try again.", comment: "Error recovery suggestion for 'not connected to the internet' error.")
|
||||
case NSURLErrorTimedOut:
|
||||
|
||||
Reference in New Issue
Block a user