FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SwinjectMVVMExample/ExampleModel/NetworkError.swift at master · Swinject/SwinjectMVVMExample · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Aug 21, 2021. It is now read-only.
Swinject
/
SwinjectMVVMExample
Public archive
Notifications
You must be signed in to change notification settings
Fork
34
Star
322
Code
Issues
1
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
SwinjectMVVMExample
/
ExampleModel
/
NetworkError.swift
Copy path
More file actions
More file actions
Latest commit
History
History
History
117 lines (108 loc) · 4.59 KB
Breadcrumbs
SwinjectMVVMExample
/
ExampleModel
/
NetworkError.swift
Copy path
File metadata and controls
117 lines (108 loc) · 4.59 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//
// NetworkError.swift
// SwinjectMVVMExample
//
// Created by Yoichi Tagaya on 8/22/15.
// Copyright © 2015 Swinject Contributors. All rights reserved.
//
import
Foundation
public
enum
NetworkError
:
Error
,
CustomStringConvertible
{
/// Unknown or not supported error.
case
Unknown
/// Not connected to the internet.
case
NotConnectedToInternet
/// International data roaming turned off.
case
InternationalRoamingOff
/// Cannot reach the server.
case
NotReachedServer
/// Connection is lost.
case
ConnectionLost
/// Incorrect data returned from the server.
case
IncorrectDataReturned
internal
init
(
error
:
NSError
)
{
if
error
.
domain
==
NSURLErrorDomain
{
switch
error
.
code
{
case
NSURLErrorUnknown
:
self
=
.
Unknown
case
NSURLErrorCancelled
:
self
=
.
Unknown // Cancellation is not used in this project.
case
NSURLErrorBadURL
:
self
=
.
IncorrectDataReturned // Because it is caused by a bad URL returned in a JSON response from the server.
case
NSURLErrorTimedOut
:
self
=
.
NotReachedServer
case
NSURLErrorUnsupportedURL
:
self
=
.
IncorrectDataReturned
case
NSURLErrorCannotFindHost
,
NSURLErrorCannotConnectToHost
:
self
=
.
NotReachedServer
case
NSURLErrorDataLengthExceedsMaximum
:
self
=
.
IncorrectDataReturned
case
NSURLErrorNetworkConnectionLost
:
self
=
.
ConnectionLost
case
NSURLErrorDNSLookupFailed
:
self
=
.
NotReachedServer
case
NSURLErrorHTTPTooManyRedirects
:
self
=
.
Unknown
case
NSURLErrorResourceUnavailable
:
self
=
.
IncorrectDataReturned
case
NSURLErrorNotConnectedToInternet
:
self
=
.
NotConnectedToInternet
case
NSURLErrorRedirectToNonExistentLocation
,
NSURLErrorBadServerResponse
:
self
=
.
IncorrectDataReturned
case
NSURLErrorUserCancelledAuthentication
,
NSURLErrorUserAuthenticationRequired
:
self
=
.
Unknown
case
NSURLErrorZeroByteResource
,
NSURLErrorCannotDecodeRawData
,
NSURLErrorCannotDecodeContentData
:
self
=
.
IncorrectDataReturned
case
NSURLErrorCannotParseResponse
:
self
=
.
IncorrectDataReturned
case
NSURLErrorInternationalRoamingOff
:
self
=
.
InternationalRoamingOff
case
NSURLErrorCallIsActive
,
NSURLErrorDataNotAllowed
,
NSURLErrorRequestBodyStreamExhausted
:
self
=
.
Unknown
case
NSURLErrorFileDoesNotExist
,
NSURLErrorFileIsDirectory
:
self
=
.
IncorrectDataReturned
case
NSURLErrorNoPermissionsToReadFile
,
NSURLErrorSecureConnectionFailed
,
NSURLErrorServerCertificateHasBadDate
,
NSURLErrorServerCertificateUntrusted
,
NSURLErrorServerCertificateHasUnknownRoot
,
NSURLErrorServerCertificateNotYetValid
,
NSURLErrorClientCertificateRejected
,
NSURLErrorClientCertificateRequired
,
NSURLErrorCannotLoadFromNetwork
,
NSURLErrorCannotCreateFile
,
NSURLErrorCannotOpenFile
,
NSURLErrorCannotCloseFile
,
NSURLErrorCannotWriteToFile
,
NSURLErrorCannotRemoveFile
,
NSURLErrorCannotMoveFile
,
NSURLErrorDownloadDecodingFailedMidStream
,
NSURLErrorDownloadDecodingFailedToComplete
:
self
=
.
Unknown
default
:
self
=
.
Unknown
}
}
else
{
self
=
.
Unknown
}
}
public
var
description
:
String
{
let
text
:
String
switch
self
{
case
.
Unknown
:
text
=
LocalizedString
(
"
NetworkError_Unknown
"
,
comment
:
"
Error description
"
)
case
.
NotConnectedToInternet
:
text
=
LocalizedString
(
"
NetworkError_NotConnectedToInternet
"
,
comment
:
"
Error description
"
)
case
.
InternationalRoamingOff
:
text
=
LocalizedString
(
"
NetworkError_InternationalRoamingOff
"
,
comment
:
"
Error description
"
)
case
.
NotReachedServer
:
text
=
LocalizedString
(
"
NetworkError_NotReachedServer
"
,
comment
:
"
Error description
"
)
case
.
ConnectionLost
:
text
=
LocalizedString
(
"
NetworkError_ConnectionLost
"
,
comment
:
"
Error description
"
)
case
.
IncorrectDataReturned
:
text
=
LocalizedString
(
"
NetworkError_IncorrectDataReturned
"
,
comment
:
"
Error description
"
)
}
return
text
}
}
Back
|
FazBrowse Home
|
New Git URL