Class: VertxWeb::ErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/error_handler.rb

Overview

A pretty error handler for rendering error pages. When working in development mode exception details will be returned in the server responses, otherwise or when manually specified no exception details are returned in the HTTP response. The reason the display of the exception details is by default dependent of the mode is to follow the security best practices: https://www.owasp.org/index.php/Improper_Error_Handling

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


25
26
27
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/error_handler.rb', line 25

def @@j_api_type.accept?(obj)
  obj.class == ErrorHandler
end

+ (::VertxWeb::ErrorHandler) create + (::VertxWeb::ErrorHandler) create(displayExceptionDetails) + (::VertxWeb::ErrorHandler) create(errorTemplateName) + (::VertxWeb::ErrorHandler) create(errorTemplateName, displayExceptionDetails)

Create an error handler

Overloads:

  • + (::VertxWeb::ErrorHandler) create(displayExceptionDetails)

    Parameters:

    • displayExceptionDetails (true, false)
      true if exception details should be displayed
  • + (::VertxWeb::ErrorHandler) create(errorTemplateName)

    Parameters:

    • errorTemplateName (String)
      the error template name - will be looked up from the classpath
  • + (::VertxWeb::ErrorHandler) create(errorTemplateName, displayExceptionDetails)

    Parameters:

    • errorTemplateName (String)
      the error template name - will be looked up from the classpath
    • displayExceptionDetails (true, false)
      true if exception details should be displayed

Returns:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/error_handler.rb', line 50

def self.create(*args)
  if !block_given? && args[0] == nil && args[1] == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandler::ErrorHandler.java_method(:create, []).call(),::VertxWeb::ErrorHandler)
  elsif (args[0].class == TrueClass || args[0].class == FalseClass) && !block_given? && args[1] == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandler::ErrorHandler.java_method(:create, [Java::boolean.java_class]).call(args[0]),::VertxWeb::ErrorHandler)
  elsif args[0].class == String && !block_given? && args[1] == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandler::ErrorHandler.java_method(:create, [Java::java.lang.String.java_class]).call(args[0]),::VertxWeb::ErrorHandler)
  elsif args[0].class == String && (args[1].class == TrueClass || args[1].class == FalseClass) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandler::ErrorHandler.java_method(:create, [Java::java.lang.String.java_class,Java::boolean.java_class]).call(args[0],args[1]),::VertxWeb::ErrorHandler)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling create(#{args[0]},#{args[1]})"
  end
end

+ (Object) DEFAULT_ERROR_HANDLER_TEMPLATE

The default template to use for rendering


81
82
83
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/error_handler.rb', line 81

def self.DEFAULT_ERROR_HANDLER_TEMPLATE
  Java::IoVertxExtWebHandler::ErrorHandler.DEFAULT_ERROR_HANDLER_TEMPLATE
end

+ (Object) j_api_type



34
35
36
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/error_handler.rb', line 34

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



37
38
39
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/error_handler.rb', line 37

def self.j_class
  Java::IoVertxExtWebHandler::ErrorHandler.java_class
end

+ (Object) unwrap(obj)



31
32
33
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/error_handler.rb', line 31

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



28
29
30
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/error_handler.rb', line 28

def @@j_api_type.wrap(obj)
  ErrorHandler.new(obj)
end

Instance Method Details

- (void) handle(event)

This method returns an undefined value.

Something has happened, so handle it.

Parameters:



70
71
72
73
74
75
76
77
78
79
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/error_handler.rb', line 70

def handle(*args)
  if args[0].class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:handle, [Java::IoVertxExtWeb::RoutingContext.java_class]).call(args[0].j_del)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling handle(#{args[0]})"
  end
end