startig with the Network Service layer for getting JSON and dealing with errors.
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
a81045e427
commit
7f2e03ed6b
25
EmployeeDirectory/Services/NetworkService.swift
Normal file
25
EmployeeDirectory/Services/NetworkService.swift
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// NetworkService.swift
|
||||||
|
// EmployeeDirectory
|
||||||
|
//
|
||||||
|
// Created by Matt Bruce on 1/20/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public enum NetworkServiceError: Error {
|
||||||
|
/// The response from the server was invalid (e.g., non-200 status code or malformed URL).
|
||||||
|
case invalidResponse
|
||||||
|
|
||||||
|
/// The url giving is invalid or malformed
|
||||||
|
case invalidURL
|
||||||
|
|
||||||
|
/// The data received was invalid or could not be decoded.
|
||||||
|
case decodingError(DecodingError)
|
||||||
|
|
||||||
|
/// A network-related error occurred.
|
||||||
|
case networkError(URLError)
|
||||||
|
|
||||||
|
/// An unexpected, uncategorized error occurred.
|
||||||
|
case unknownError(Error)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user