Skip to content

Commit 6179f9b

Browse files
committed
Improve error handling in BlinkClient for non-MP4 videos
Enhance error reporting by attempting to read the response content when the `contentType` is not `"video/mp4"`. If the response content cannot be read, include the exception message in the error details. This provides more context in the `BlinkClientException` for debugging issues.
1 parent 61a773c commit 6179f9b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Sources/Blink/BlinkClient.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,22 @@ public async Task<byte[]> GetVideoBytesAsync(BlinkVideoInfo video, int tryCount
271271
return await response.Content.ReadAsByteArrayAsync();
272272
}
273273
}
274-
throw new BlinkClientException($"Failed to get video {video.Id}, contentType {contentType} - {response?.ReasonPhrase ?? "Unknown Error"}. Please create an issue if you see this error.");
274+
275+
// DEBUG: try to read response content for better error message if not video/mp4
276+
string responseContent = "No response";
277+
if (response != null)
278+
{
279+
try
280+
{
281+
responseContent = await response.Content.ReadAsStringAsync();
282+
}
283+
catch (Exception ex)
284+
{
285+
responseContent = "Failed to read response content: " + ex.Message;
286+
}
287+
}
288+
throw new BlinkClientException($"Failed to get video {video.Id}, contentType {contentType} - {response?.ReasonPhrase ?? "Unknown Error"}. " +
289+
$"Please create an issue if you see this error. Content: " + responseContent);
275290
}
276291

277292
/// <summary>

0 commit comments

Comments
 (0)