From 7f2e03ed6b21d6541c46eb82981aa18846942431 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 20 Jan 2025 16:49:52 -0600 Subject: [PATCH] startig with the Network Service layer for getting JSON and dealing with errors. Signed-off-by: Matt Bruce --- .../Services/NetworkService.swift | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 EmployeeDirectory/Services/NetworkService.swift diff --git a/EmployeeDirectory/Services/NetworkService.swift b/EmployeeDirectory/Services/NetworkService.swift new file mode 100644 index 0000000..5fb1366 --- /dev/null +++ b/EmployeeDirectory/Services/NetworkService.swift @@ -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) +}