Yep, the attachments processing has changed quite a bit...
If you look into Post.controller.php, the code to create an attachment is rather simple:
// Then try to upload any attachments.
$context['can_post_attachment'] = !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1 && (allowedTo('post_attachment') || ($modSettings['postmod_active'] && allowedTo('post_unapproved_attachments')));
if ($context['can_post_attachment'] && empty($_POST['from_qr']))
{
require_once(SUBSDIR . '/Attachments.subs.php');
if (isset($_REQUEST['msg']))
processAttachments((int) $_REQUEST['msg']);
else
processAttachments();
}
and slightly below:
// Any mistakes?
if ($post_errors->hasErrors() || $attach_errors->hasErrors())
{
// Previewing.
$_REQUEST['preview'] = true;
return $this->action_post();
}
and finally the block after the comment:
// ...or attach a new file...
Attachments are not yet that independent from messages, but at least their processing is.
In your case, you should be able to prepare the attachments with just the first block of code (the one containing processAttachments()), and then Post.controller.php will take care of associating the attachment to the proper message... I think/hope.
And you can use the static class:
$attach_errors = attachment_Error_Context::context();
to catch any error while attaching a file.