surface agent stream audit IDs
This commit is contained in:
@@ -567,6 +567,11 @@ class ApiRepository {
|
||||
final streamed = await client
|
||||
.send(request)
|
||||
.timeout(const Duration(minutes: 10));
|
||||
final auditId = streamed.headers['x-agent-audit-id'];
|
||||
String withAuditId(String message) =>
|
||||
auditId == null || auditId.isEmpty
|
||||
? message
|
||||
: '$message\nمعرّف تتبع الطلب: $auditId';
|
||||
if (streamed.statusCode < 200 || streamed.statusCode >= 300) {
|
||||
final response = await http.Response.fromStream(streamed);
|
||||
_checkStatus(response);
|
||||
@@ -601,9 +606,11 @@ class ApiRepository {
|
||||
eventName = null;
|
||||
}
|
||||
}
|
||||
if (streamError != null) throw Exception(streamError);
|
||||
if (streamError != null) throw Exception(withAuditId(streamError));
|
||||
final data = resultData;
|
||||
if (data == null) throw Exception('انقطع اتصال البث قبل اكتمال الوكيل.');
|
||||
if (data == null) {
|
||||
throw Exception(withAuditId('انقطع اتصال البث قبل اكتمال الوكيل.'));
|
||||
}
|
||||
return AgentRunResult.fromApiData(data);
|
||||
} finally {
|
||||
if (identical(_activeRequestClient, client)) _activeRequestClient = null;
|
||||
|
||||
Reference in New Issue
Block a user