|
|
@@ -2163,7 +2163,7 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
|
|
|
self.chatMessages.append(ChatMessage(role: "assistant", content: reply, attachedJobs: freshJobs.isEmpty ? nil : freshJobs))
|
|
|
self.appendChatBubble(text: reply, isUser: false, jobs: freshJobs)
|
|
|
case .failure(let error):
|
|
|
- self.appendChatBubble(text: error.localizedDescription, isUser: false)
|
|
|
+ self.appendChatBubble(text: UserFacingErrorMessage.jobSearchFailure(error), isUser: false)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2920,7 +2920,7 @@ private final class OpenAIJobSearchService {
|
|
|
completion(.failure(NSError(
|
|
|
domain: "OpenAIJobSearchService",
|
|
|
code: 1,
|
|
|
- userInfo: [NSLocalizedDescriptionKey: "Missing API key. Set OPENAI_API_KEY in Xcode Build Settings."]
|
|
|
+ userInfo: [NSLocalizedDescriptionKey: "Job search is unavailable."]
|
|
|
)))
|
|
|
return
|
|
|
}
|
|
|
@@ -2995,19 +2995,12 @@ private final class OpenAIJobSearchService {
|
|
|
return
|
|
|
}
|
|
|
if let http = response as? HTTPURLResponse, !(200...299).contains(http.statusCode) {
|
|
|
- if let apiError = try? JSONDecoder().decode(OpenAIAPIErrorResponse.self, from: data) {
|
|
|
- completion(.failure(NSError(
|
|
|
- domain: "OpenAIJobSearchService",
|
|
|
- code: http.statusCode,
|
|
|
- userInfo: [NSLocalizedDescriptionKey: apiError.error.message]
|
|
|
- )))
|
|
|
- } else {
|
|
|
- completion(.failure(NSError(
|
|
|
- domain: "OpenAIJobSearchService",
|
|
|
- code: http.statusCode,
|
|
|
- userInfo: [NSLocalizedDescriptionKey: "Job search request failed with status \(http.statusCode)."]
|
|
|
- )))
|
|
|
- }
|
|
|
+ _ = try? JSONDecoder().decode(OpenAIAPIErrorResponse.self, from: data)
|
|
|
+ completion(.failure(NSError(
|
|
|
+ domain: "OpenAIJobSearchService",
|
|
|
+ code: http.statusCode,
|
|
|
+ userInfo: [NSLocalizedDescriptionKey: "Job search request failed."]
|
|
|
+ )))
|
|
|
return
|
|
|
}
|
|
|
do {
|
|
|
@@ -3051,8 +3044,11 @@ private final class OpenAIJobSearchService {
|
|
|
}
|
|
|
if let status = root["status"] as? String {
|
|
|
if status == "failed" {
|
|
|
- let message = (root["error"] as? [String: Any])?["message"] as? String ?? "The search request failed."
|
|
|
- throw NSError(domain: "OpenAIJobSearchService", code: 7, userInfo: [NSLocalizedDescriptionKey: message])
|
|
|
+ throw NSError(
|
|
|
+ domain: "OpenAIJobSearchService",
|
|
|
+ code: 7,
|
|
|
+ userInfo: [NSLocalizedDescriptionKey: "The search request failed."]
|
|
|
+ )
|
|
|
}
|
|
|
if status == "incomplete",
|
|
|
let details = root["incomplete_details"] as? [String: Any],
|