Exception: CentralMail::UploadError
- Inherits:
-
StandardError
- Object
- StandardError
- CentralMail::UploadError
- Defined in:
- lib/central_mail/upload_error.rb
Constant Summary collapse
- DEFAULT_MESSAGE =
'Internal Server Error'
- DOC101 =
DOC1xx errors: client errors, invalid submissions
'Invalid multipart payload'
- DOC102 =
'Invalid metadata part'
- DOC103 =
'Invalid content part'
- DOC104 =
'Upload rejected by upstream system'
- DOC105 =
'Invalid or unknown id'
- DOC106 =
'Maximum document size exceeded.'
- DOC107 =
'Empty payload'
- DOC108 =
'Maximum page size exceeded.'
- DOC201 =
DOC2xx errors: server errors either local or upstream not unambiguously related to submitted content
'Upload server error. Request will be retried when upstream service is available.'
- DOC202 =
'Error during processing by upstream system'
- STATSD_UPLOAD_FAIL_KEY =
'api.central_mail.upload.fail'
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#detail ⇒ Object
Returns the value of attribute detail.
-
#upstream_http_resp_status ⇒ Object
Returns the value of attribute upstream_http_resp_status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message = nil, code: nil, detail: nil, upstream_http_resp_status: nil, pdf_validator_options: {}) ⇒ UploadError
constructor
A new instance of UploadError.
Constructor Details
#initialize(message = nil, code: nil, detail: nil, upstream_http_resp_status: nil, pdf_validator_options: {}) ⇒ UploadError
Returns a new instance of UploadError.
48 49 50 51 52 53 54 55 |
# File 'lib/central_mail/upload_error.rb', line 48 def initialize( = nil, code: nil, detail: nil, upstream_http_resp_status: nil, pdf_validator_options: {}) super( || UploadError.(code, )) @code = code @detail = detail @upstream_http_resp_status = upstream_http_resp_status StatsD.increment self.class::STATSD_UPLOAD_FAIL_KEY, tags: ["status:#{code}"] end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
8 9 10 |
# File 'lib/central_mail/upload_error.rb', line 8 def code @code end |
#detail ⇒ Object
Returns the value of attribute detail.
8 9 10 |
# File 'lib/central_mail/upload_error.rb', line 8 def detail @detail end |
#upstream_http_resp_status ⇒ Object
Returns the value of attribute upstream_http_resp_status.
8 9 10 |
# File 'lib/central_mail/upload_error.rb', line 8 def upstream_http_resp_status @upstream_http_resp_status end |
Class Method Details
.default_message(code, pdf_validator_options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/central_mail/upload_error.rb', line 29 def self.(code, = {}) begin = UploadError.const_get(code.to_sym) rescue NameError = DEFAULT_MESSAGE end opts = PDFUtilities::PDFValidator::Validator::DEFAULT_OPTIONS.merge(.to_h) case code.to_s when 'DOC106' "#{} Limit is #{PDFUtilities.formatted_file_size(opts[:size_limit_in_bytes])} per document." when 'DOC108' "#{} Limit is #{opts[:width_limit_in_inches]} in x #{opts[:height_limit_in_inches]} in." else end end |