mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
avoid fatal error
This commit is contained in:
@@ -120,9 +120,9 @@ class ImmichAPI {
|
|||||||
private func buildRequestURL(
|
private func buildRequestURL(
|
||||||
endpoint: String,
|
endpoint: String,
|
||||||
params: [URLQueryItem] = []
|
params: [URLQueryItem] = []
|
||||||
) -> URL? {
|
) throws(FetchError) -> URL? {
|
||||||
guard let baseURL = URL(string: serverEndpoint) else {
|
guard let baseURL = URL(string: serverEndpoint) else {
|
||||||
fatalError("Invalid base URL")
|
throw FetchError.invalidURL
|
||||||
}
|
}
|
||||||
|
|
||||||
let fullPath = baseURL.appendingPathComponent(
|
let fullPath = baseURL.appendingPathComponent(
|
||||||
@@ -145,7 +145,7 @@ class ImmichAPI {
|
|||||||
-> [Asset]
|
-> [Asset]
|
||||||
{
|
{
|
||||||
guard
|
guard
|
||||||
let searchURL = buildRequestURL(endpoint: "/search/random")
|
let searchURL = try buildRequestURL(endpoint: "/search/random")
|
||||||
else {
|
else {
|
||||||
throw URLError(.badURL)
|
throw URLError(.badURL)
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ class ImmichAPI {
|
|||||||
func fetchMemory(for date: Date) async throws -> [MemoryResult] {
|
func fetchMemory(for date: Date) async throws -> [MemoryResult] {
|
||||||
let memoryParams = [URLQueryItem(name: "for", value: date.ISO8601Format())]
|
let memoryParams = [URLQueryItem(name: "for", value: date.ISO8601Format())]
|
||||||
guard
|
guard
|
||||||
let searchURL = buildRequestURL(
|
let searchURL = try buildRequestURL(
|
||||||
endpoint: "/memories",
|
endpoint: "/memories",
|
||||||
params: memoryParams
|
params: memoryParams
|
||||||
)
|
)
|
||||||
@@ -182,7 +182,7 @@ class ImmichAPI {
|
|||||||
let assetEndpoint = "/assets/" + asset.id + "/thumbnail"
|
let assetEndpoint = "/assets/" + asset.id + "/thumbnail"
|
||||||
|
|
||||||
guard
|
guard
|
||||||
let fetchURL = buildRequestURL(
|
let fetchURL = try buildRequestURL(
|
||||||
endpoint: assetEndpoint,
|
endpoint: assetEndpoint,
|
||||||
params: thumbnailParams
|
params: thumbnailParams
|
||||||
)
|
)
|
||||||
@@ -220,7 +220,7 @@ class ImmichAPI {
|
|||||||
|
|
||||||
func fetchAlbums() async throws -> [Album] {
|
func fetchAlbums() async throws -> [Album] {
|
||||||
guard
|
guard
|
||||||
let searchURL = buildRequestURL(endpoint: "/albums")
|
let searchURL = try buildRequestURL(endpoint: "/albums")
|
||||||
else {
|
else {
|
||||||
throw URLError(.badURL)
|
throw URLError(.badURL)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user