Module: SimpleJSON::CrashProof

Defined in:
lib/simple_json_helpers.rb

Overview

///////////////////////////////////////////////////////////////////////////////////////

Author

lp ([email protected])

Copyright

2009 Louis-Philippe Perron - Released under the terms of the MIT license

:title:SimpleJSON::CrashProof

Class Method Summary collapse

Class Method Details

.wrap(&block) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/simple_json_helpers.rb', line 47

def self.wrap(&block)
	begin
		block.call
	rescue
		[200, {	'Content-Type' => 'application/json' }, "{\"ERROR\":{\"class\":\"#{$!.class}\",\"message\":\"#{$!.message}\"}}"]
	end
end