fal-swift
fal-swift copied to clipboard
feature request: include request id in error result
Using the realtime
client, our onResult
handler can currently use the request_id
parameter to identify the request corresponding to an api call, if that call is successful. However, since the onResult
callback is typed as @escaping (Result<Output, Error>) -> Void
, we can't identify requests for api call failures in the same way.
Some example code demonstrating the issue:
connection = try! falClient.realtime.connect(
to: OptimizedLatentConsistency,
connectionKey: "ReproDemo",
throttleInterval: .milliseconds(0), // no need to throttle since i'm calling generate in response to a button tap
onResult: { (result: Result<LcmResponse, Error>) in
switch result {
case .success(let data):
// Can do things with data.requestId here
print(data.requestId!)
case .failure(let error):
// ISSUE: Can't tie this back to the originating request, since there's no way to access request_id
print(error)
}
}
)
Thanks for bringing this up @jb-delightai. You're absolutely right, we need to add the request id to the errors. I'll work on it and let you know once it's fixed.