Improve Error Messaging for Media Upload Failures #1244
Open
Description
The error "Missing 'media_id_string'" is misleading when the actual issue is unrelated to media upload, such as an expired user token. Update error handling to display specific API error messages or fallback to the generic message:
private function uploadMediaChunked(string $path, array $parameters)
{
/** @var object $init */
$init = $this->http(
'POST',
self::UPLOAD_HOST,
$path,
$this->mediaInitParameters($parameters),
['jsonPayload' => false],
);
if (!property_exists($init, 'media_id_string')) {
throw new TwitterOAuthException($init->errors[0]->message ?? 'Missing "media_id_string"');
}
.....