Add comprehensive error message parsing to prevent raw JSON display
- Created ErrorMessageParser utility for both iOS (Swift) and Android (Kotlin) - Parser detects JSON-formatted error messages and extracts user-friendly text - Identifies when data objects (not errors) are returned and provides generic messages - Updated all API error handling to pass raw error bodies instead of concatenating - Applied ErrorMessageParser across all ViewModels and screens on both platforms - Fixed ContractorApi and DocumentApi to not concatenate error bodies with messages - Updated ApiResultHandler to automatically parse all error messages - Error messages now show "Request failed. Please check your input and try again." instead of raw JSON 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -278,6 +278,10 @@ struct CompleteTaskView: View {
|
||||
.onAppear {
|
||||
contractorViewModel.loadContractors()
|
||||
}
|
||||
.handleErrors(
|
||||
error: errorMessage,
|
||||
onRetry: { handleComplete() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +128,10 @@ struct EditTaskView: View {
|
||||
.onAppear {
|
||||
loadLookups()
|
||||
}
|
||||
.handleErrors(
|
||||
error: viewModel.errorMessage,
|
||||
onRetry: { submitForm() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,3 +185,4 @@ struct EditTaskView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class TaskViewModel: ObservableObject {
|
||||
break
|
||||
} else if let error = state as? ApiResultError {
|
||||
await MainActor.run {
|
||||
self.errorMessage = error.message
|
||||
self.errorMessage = ErrorMessageParser.parse(error.message)
|
||||
self.isLoading = false
|
||||
}
|
||||
sharedViewModel.resetAddTaskState()
|
||||
|
||||
Reference in New Issue
Block a user