I would like to print out the cause of the error.
error_get_last() doesn’t seem to return anything. rename() returns TRUE|FALSE rather than an exception.
if (!rename($file->filepath, $full_path)) {
$error = error_get_last();
watchdog('name', "Failed to move the uploaded file from %source to %dest", array('%source' => $file->filepath, '%dest' => $full_path));
}
The answer was ‘another error handler’ was capturing the errors as per the comment in the php manual for http://php.net/manual/en/function.error-get-last.php. In this case it was the drupal error handler and the error was being captured into the error log there.