From 2f3deee33f9c83ca8bb0a9b55fc9b7621e88b978 Mon Sep 17 00:00:00 2001 From: schochastics Date: Wed, 6 Nov 2024 19:56:05 +0100 Subject: [PATCH] added error when media couldn't be uploaded --- R/post.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/post.R b/R/post.R index cf8ea9b..7d82feb 100644 --- a/R/post.R +++ b/R/post.R @@ -83,6 +83,10 @@ upload_media_to_mastodon <- function(media, alt_text, token) { body = params, httr::add_headers(Authorization = paste0("Bearer ", token$bearer)) ) + if (httr::status_code(r) != 200) { + stop(paste0("Error while uploading: ", media, ". Status Code:", httr::status_code(r))) + } + httr::content(r)$id }