From 09841c5b5598ff4adb730bc777985581b82a002b Mon Sep 17 00:00:00 2001 From: BrokenEagle Date: Wed, 29 Jan 2020 22:24:23 +0000 Subject: [PATCH] Fix errors caused by Pawoo exceptions --- app/logical/pawoo_api_client.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/logical/pawoo_api_client.rb b/app/logical/pawoo_api_client.rb index 4a41af238..20daf1fd7 100644 --- a/app/logical/pawoo_api_client.rb +++ b/app/logical/pawoo_api_client.rb @@ -109,11 +109,26 @@ class PawooApiClient def get(url) if id = Status.is_match?(url) - return Status.new(JSON.parse(access_token.get("/api/v1/statuses/#{id}").body)) + begin + data = JSON.parse(access_token.get("/api/v1/statuses/#{id}").body) + rescue + data = { + "account" => {}, + "media_attachments" => [], + "tags" => [], + "content" => "", + } + end + return Status.new(data) end if id = Account.is_match?(url) - return Account.new(JSON.parse(access_token.get("/api/v1/accounts/#{id}").body)) + begin + data = JSON.parse(access_token.get("/api/v1/accounts/#{id}").body) + rescue + data = {} + end + return Account.new(data) end end