-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
151 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Lingua Documentation | ||
|
||
Welcome to the main documentation repository for **Lingua**. This directory provides a comprehensive guide to our tool, covering both its usage and underlying architecture. Here's a breakdown of the two main sections: | ||
|
||
## 1. [App - Usage & Best Practices](./App/) | ||
|
||
This section focuses on helping users effectively utilize "Your Tool Name". Here, you'll find: | ||
|
||
- **Usage Instructions**: Step-by-step guides on how to get started and utilize the main features of our tool. | ||
- **Best Practices**: Tips and recommendations for maximizing the utility and efficiency of **Lingua**. | ||
- ... and more! | ||
|
||
[📁 Click here to explore the App documentation](./App/) | ||
|
||
## 2. [Lingua Architecture](./Architecture/) | ||
|
||
Dive deeper into the design and structure of **Lingua** with our architecture documentation. This section provides insights into: | ||
|
||
- **System Design**: Understand the overall system layout and how different components interact. | ||
- **Technical Specs**: Details about the technologies used, data flow diagrams, and more. | ||
- ... and other technical insights! | ||
|
||
[📁 Click here to explore the Lingua Architecture documentation](./Architecture/) | ||
|
||
--- | ||
|
||
We encourage users to familiarize themselves with both sections to fully understand and utilize **Lingua** to its maximum potential. If you have further questions or feedback, please don't hesitate to reach out. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Sources/Lingua/Infrastructure/Data/GoogleSheets/Fetcher/GoogleSheetsErrorHandler.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Foundation | ||
|
||
final class GoogleSheetsErrorHandler: APIErrorHandler { | ||
private let decoder: JSONDecoding | ||
|
||
init(decoder: JSONDecoding = JSONDecoder()) { | ||
self.decoder = decoder | ||
} | ||
|
||
func handleError<T: Decodable>(data: Data, statusCode: Int) throws -> T { | ||
if let googleError = try? decoder.decode(GoogleSheetErrorResponse.self, from: data) { | ||
throw GoogleSheetsError(from: googleError) | ||
} else { | ||
throw InvalidHTTPResponseError(statusCode: statusCode, data: data) | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...es/Lingua/Infrastructure/Data/GoogleSheets/Models/Response/GoogleSheetErrorResponse.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Foundation | ||
|
||
struct GoogleSheetErrorResponse: Codable { | ||
let error: ErrorResponse | ||
|
||
struct ErrorResponse: Codable { | ||
let code: Int | ||
let message: String | ||
let status: Status | ||
} | ||
|
||
enum Status: String, Codable { | ||
case permissionDenied = "PERMISSION_DENIED" | ||
case notFound = "NOT_FOUND" | ||
case invalidArgument = "INVALID_ARGUMENT" | ||
|
||
var description: String { | ||
switch self { | ||
case .permissionDenied: | ||
return """ | ||
Ensure that the Google Sheet you're trying to access has its sharing | ||
settings configured to allow access to anyone with the link. You can do this by | ||
clicking on \"Share\" in the upper right corner of the Google Sheet and | ||
selecting \"Anyone with the link.\" | ||
""" | ||
case .notFound: | ||
return """ | ||
The resource you're trying to access couldn't be found. | ||
Please ensure you're looking in the right place and the sheet id is correct. | ||
""" | ||
case .invalidArgument: | ||
return """ | ||
It seems there was an error with the data provided. | ||
Please check your inputs and try again. | ||
""" | ||
} | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Sources/Lingua/Infrastructure/Data/GoogleSheets/Models/Response/GoogleSheetsError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
|
||
struct GoogleSheetsError: LocalizedError { | ||
private let response: GoogleSheetErrorResponse | ||
|
||
init(from response: GoogleSheetErrorResponse) { | ||
self.response = response | ||
} | ||
|
||
var errorDescription: String? { | ||
"\(response.error.message)\n" + "Additional info: \(response.error.status.description)" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
Sources/Lingua/Infrastructure/Networking/RequestExecutor/APIErrorHandler.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
|
||
protocol APIErrorHandler { | ||
func handleError<T: Decodable>(data: Data, statusCode: Int) throws -> T | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters