简体   繁体   中英

rescue from RestClient::NotFound doesn't work

After RestClient.get "some_url" i get RestClient::NotFound error. Despite having rescue block, i still getting this error instead my custom error, that raising in rescue block:

def get_video(id)
        RestClient.get "#{BASE_URL}/videos/#{id}", headers
rescue RestClient::NotFound
        Rails.logger.info("Video with #{id} vimeo_video_id was not found!")
        raise Vimeo::VimeoVideoNotFoundError
end

Use the begin keyword also. the gem gave an example also on how to use the various types of Exceptions raised here

def get_video(id)
begin
        RestClient.get "#{BASE_URL}/videos/#{id}", headers
rescue RestClient::NotFound
        Rails.logger.info("Video with #{id} vimeo_video_id was not found!")
        raise Vimeo::VimeoVideoNotFoundError
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM