handle canvadoc 500s too

closes FOO-1317
flag=none

TEST PLAN:
  1) make canvadocs returen 500s
  2) treat as service unavailable
  3) no sentry report

Change-Id: Id3040aaf131d6af7707a3556e3b705b50ca9707d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/254840
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Charley Kline <ckline@instructure.com>
Product-Review: Charley Kline <ckline@instructure.com>
QA-Review: Ethan Vizitei <evizitei@instructure.com>
This commit is contained in:
Ethan Vizitei 2020-12-10 13:01:30 -06:00
parent 24ee8e62b2
commit 1517d352a2
2 changed files with 6 additions and 1 deletions

View File

@ -87,12 +87,15 @@ class CanvadocSessionsController < ApplicationController
rescue HmacHelper::Error => e
Canvas::Errors.capture_exception(:canvadocs, e, :info)
render :plain => 'unauthorized', :status => :unauthorized
rescue Timeout::Error, Canvadocs::BadGateway => e
rescue Timeout::Error, Canvadocs::BadGateway, Canvadocs::ServerError => e
Canvas::Errors.capture_exception(:canvadocs, e, :warn)
render :plain => "Service is currently unavailable. Try again later.",
:status => :service_unavailable
rescue Canvadocs::BadRequest => e
Canvas::Errors.capture_exception(:canvadocs, e, :info)
render :plain => 'Canvadocs Bad Request', :status => :bad_request
rescue Canvadocs::HttpError => e
Canvas::Errors.capture_exception(:canvadocs, e, :error)
render :plain => 'Unknown Canvadocs Error', :status => :service_unavailable
end
end

View File

@ -149,6 +149,7 @@ module Canvadocs
unless response.code =~ /\A20./
err_message = "HTTP Error #{response.code}: #{response.body}"
klass = Canvadocs::HttpError
klass = Canvadocs::ServerError if response.code.to_s == "500"
klass = Canvadocs::BadGateway if response.code.to_s == "502"
klass = Canvadocs::BadRequest if response.code.to_s == "400"
raise klass, err_message
@ -199,6 +200,7 @@ module Canvadocs
class Error < StandardError; end
class HttpError < Error; end
class ServerError < HttpError; end
class BadGateway < HttpError; end
class BadRequest < HttpError; end