Exception: ExceptionHandler
- Inherits:
-
StandardError
- Object
- StandardError
- ExceptionHandler
- Defined in:
- lib/exception_handler.rb
Class Method Summary collapse
-
.before(datas) ⇒ Object
Minimum required parameters.
-
.on_launch(datas) ⇒ Object
Check if the request is ok.
Class Method Details
.before(datas) ⇒ Object
Minimum required parameters
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/exception_handler.rb', line 4 def self.before(datas) required_params = [ 'merchant_id', 'amount', 'customer_id', 'cancel_return_url', 'normal_return_url', 'automatic_response_url' ] required_params.each do |r| raise "Atos plugin error : missing parameter '#{r}' in request" if !datas[r.to_sym] end end |
.on_launch(datas) ⇒ Object
Check if the request is ok
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/exception_handler.rb', line 22 def self.on_launch(datas) response_array = datas.split("!") case response_array[1] when nil # No response at all from API raise "Atos plugin error : binary file does not respond ! Check your 'request' binary path, default is 'Rails.root/lib/atos/bin'" when "0" # API respond 'ok', return the content response_array else # API binary respond an error, formated in an HTML table. Let's strip tags before showing the error message raise "Atos API binary file outputs : #{response_array[2].gsub(/<\/?[^>]*>/, '')}" end end |