| 
									
										
										
										
											2015-11-02 17:33:25 +03:00
										 |  |  | require "json" | 
					
						
							| 
									
										
										
										
											2015-10-09 15:00:21 +03:00
										 |  |  | module Devops | 
					
						
							|  |  |  |   module Exception | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     class DevopsError < StandardError | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-02 17:33:25 +03:00
										 |  |  |       def http_status | 
					
						
							| 
									
										
										
										
											2015-10-09 15:00:21 +03:00
										 |  |  |         500
 | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-02 17:33:25 +03:00
										 |  |  |       def http_response | 
					
						
							|  |  |  |         [self.http_status, self.http_headers, self.http_body] | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       def http_body | 
					
						
							| 
									
										
										
										
											2016-02-24 14:33:02 +03:00
										 |  |  |         error_body = {message: self.message} | 
					
						
							|  |  |  |         error_body[:error_type] = error_type if respond_to?(:error_type) | 
					
						
							|  |  |  |         JSON.pretty_generate(error_body) | 
					
						
							| 
									
										
										
										
											2015-11-02 17:33:25 +03:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       def http_headers | 
					
						
							|  |  |  |         {"Content-Type" => "application/json"} | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-09 15:00:21 +03:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |