lib/rest-ftp-daemon/api/root.rb in rest-ftp-daemon-1.0.9 vs lib/rest-ftp-daemon/api/root.rb in rest-ftp-daemon-1.0.10

- old
+ new

@@ -31,10 +31,16 @@ def exception_error error, http_code, exception, message = nil # Extract message lines lines = exception.message.lines + # Add some backtrace lines + http500_backtrace = LOG_HTP500_BACKTRACE.to_i + unless LOG_HTP500_BACKTRACE.to_i.zero? + lines += exception.backtrace[0..http500_backtrace] if exception.backtrace.is_a?(Array) + end + # Log error to file log_error "[#{error}] [#{http_code}] #{lines.shift} ", lines # Default to exeption message if empty message ||= exception.message @@ -57,17 +63,18 @@ log_request end ## EXCEPTION HANDLERS - # rescue_from Grape::Exceptions::ValidationErrors do |exception| - # exception_error :api_content_type, 406, exception, "The requested content-type is not supported" - # end - rescue_from Grape::Exceptions::InvalidMessageBody do |exception| exception_error :api_invalid_message_body, 400, exception, "Bad request: message body does not match declared format, check command syntax" end - + rescue_from RestFtpDaemon::SchemeUnsupported do |exception| + exception_error :unsupported_scheme, 422, exception, "Bad request: unsupported scheme" + end + rescue_from RestFtpDaemon::LocationParseError do |exception| + exception_error :location_parse_error, 422, exception, "Bad request: location parse error" + end rescue_from :all do |exception| exception_error :api_error, 500, exception end \ No newline at end of file