Exception: Tilia::Dav::Exception::PreconditionFailed

Inherits:
Tilia::Dav::Exception show all
Defined in:
lib/tilia/dav/exception/precondition_failed.rb

Overview

PreconditionFailed

This exception is normally thrown when a client submitted a conditional request, like for example an If, If-None-Match or If-Match header, which caused the HTTP request to not execute (the condition of the header failed)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Tilia::Dav::Exception

#http_headers

Constructor Details

#initialize(header = nil) ⇒ PreconditionFailed

Create the exception

Parameters:

  • string

    $message

  • string

    $header



22
23
24
# File 'lib/tilia/dav/exception/precondition_failed.rb', line 22

def initialize(header = nil)
  self.header = header
end

Instance Attribute Details

#headerObject

When this exception is thrown, the header-name might be set.

This allows the exception-catching code to determine which HTTP header caused the exception.



16
17
18
# File 'lib/tilia/dav/exception/precondition_failed.rb', line 16

def header
  @header
end

Instance Method Details

#http_codeObject

Returns the HTTP statuscode for this exception

Returns:

  • int



29
30
31
# File 'lib/tilia/dav/exception/precondition_failed.rb', line 29

def http_code
  412
end

#serialize(_server, error_node) ⇒ Object

This method allows the exception to include additional information into the WebDAV error response

Parameters:

  • DAV\Server

    server

  • \DOMElement

    error_node

Returns:

  • void



38
39
40
41
42
43
# File 'lib/tilia/dav/exception/precondition_failed.rb', line 38

def serialize(_server, error_node)
  if header
    prop = LibXML::XML::Node.new('s:header', header)
    error_node << prop
  end
end