### Home Classes Methods

### In Files

- lib/chef/handler/error_report.rb
- lib/chef/handler/json_file.rb
- lib/chef/handler.rb

### Parent

Object

### Namespace

- CLASS Chef::Handler::ErrorReport
- CLASS Chef::Handler::JsonFile

### Methods

- ::exception_handlers
- ::report_handlers
- ::run_exception_handlers
- ::run_report_handlers
- ::run_start_handlers
- ::start_handlers
- #all_resources
- #backtrace
- #data
- #elapsed_time
- #end_time
- #exception
- #failed?
- #node
- #report
- #run_context
- #run_report_safely
- #run_report_unsafe
- #start_time
- #success?
- #updated_resources

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- Chef
- Chef::ApiClient
- Chef::Application
- Chef::Application::Client
- Chef::Application::Knife
- Chef::Application::Solo
- Chef::Application::Wakeup
- Chef::Application::WindowsService
- Chef::Certificate
- Chef::Checksum
- Chef::Checksum::Storage
- Chef::Checksum::Storage::Filesystem
- Chef::ChecksumCache
- Chef::Client
- Chef::Config
- Chef::Cookbook
- Chef::Cookbook::Chefignore
- Chef::Cookbook::CookbookVersionLoader
- Chef::Cookbook::FileSystemFileVendor
- Chef::Cookbook::FileVendor
- Chef::Cookbook::Metadata
- Chef::Cookbook::MinimalMetadata
- Chef::Cookbook::RemoteFileVendor
- Chef::Cookbook::SyntaxCheck
- Chef::CookbookCacheCleaner
- Chef::CookbookCollection
- Chef::CookbookLoader
- Chef::CookbookSiteStreamingUploader
- Chef::CookbookSiteStreamingUploader::MultipartStream
- Chef::CookbookSiteStreamingUploader::StreamPart
- Chef::CookbookSiteStreamingUploader::StringPart
- Chef::CookbookSynchronizer
- Chef::CookbookUploader
- Chef::CookbookVersion
- Chef::CookbookVersionSelector
- Chef::CouchDB
- Chef::Daemon
- Chef::DataBag
- Chef::DataBagItem
- Chef::EncryptedDataBagItem
- Chef::EncryptedDataBagItem::DecryptionFailure
- Chef::EncryptedDataBagItem::Decryptor
- Chef::EncryptedDataBagItem::Decryptor::Version0Decryptor
- Chef::EncryptedDataBagItem::Decryptor::Version1Decryptor
- Chef::EncryptedDataBagItem::UnsupportedCipher
- Chef::EncryptedDataBagItem::UnsupportedEncryptedDataBagItemFormat
- Chef::Environment
- Chef::EventDispatch
- Chef::EventDispatch::Base
- Chef::EventDispatch::Dispatcher
- Chef::Exceptions
- Chef::Exceptions::AmbiguousRunlistSpecification
- Chef::Exceptions::Application
- Chef::Exceptions::AttributeNotFound
- Chef::Exceptions::CannotDetermineNodeName
- Chef::Exceptions::CannotWritePrivateKey
- Chef::Exceptions::CommandTimeout
- Chef::Exceptions::ConfigurationError
- Chef::Exceptions::CookbookFrozen
- Chef::Exceptions::CookbookNotFound
- Chef::Exceptions::CookbookNotFoundInRepo
- Chef::Exceptions::CookbookVersionConflict
- Chef::Exceptions::CookbookVersionNameMismatch
- Chef::Exceptions::CookbookVersionSelection
- Chef::Exceptions::CookbookVersionSelection::InvalidRunListItems
- Chef::Exceptions::CookbookVersionSelection::UnsatisfiableRunListItem
- Chef::Exceptions::CouchDBNotFound
- Chef::Exceptions::Cron
- Chef::Exceptions::DsclCommandFailed
- Chef::Exceptions::EnclosingDirectoryDoesNotExist
- Chef::Exceptions::Env
- Chef::Exceptions::ErlCall
- Chef::Exceptions::Exec
- Chef::Exceptions::FileNotFound
- Chef::Exceptions::Group
- Chef::Exceptions::GroupIDNotFound
- Chef::Exceptions::Ifconfig
- Chef::Exceptions::IllegalChecksumRevert
- Chef::Exceptions::InsufficientPermissions
- Chef::Exceptions::InvalidCommandOption
- Chef::Exceptions::InvalidCookbookVersion
- Chef::Exceptions::InvalidDataBagItemID
- Chef::Exceptions::InvalidDataBagName
- Chef::Exceptions::InvalidDataBagPath
- Chef::Exceptions::InvalidEnvironmentRunListSpecification
- Chef::Exceptions::InvalidHomeDirectory
- Chef::Exceptions::InvalidPrivateKey
- Chef::Exceptions::InvalidRemoteGitReference
- Chef::Exceptions::InvalidResourceReference
- Chef::Exceptions::InvalidResourceSpecification
- Chef::Exceptions::InvalidVersionConstraint
- Chef::Exceptions::Link
- Chef::Exceptions::MissingLibrary
- Chef::Exceptions::MissingParentDirectory
- Chef::Exceptions::MissingRole
- Chef::Exceptions::Mount
- Chef::Exceptions::ObsoleteDependencySyntax
- Chef::Exceptions::Override
- Chef::Exceptions::Package
- Chef::Exceptions::PrivateKeyMissing
- Chef::Exceptions::QueryParseError
- Chef::Exceptions::RecipeNotFound
- Chef::Exceptions::RedirectLimitExceeded
- Chef::Exceptions::RequestedUIDUnavailable
- Chef::Exceptions::ResourceNotFound
- Chef::Exceptions::RoleNotFound
- Chef::Exceptions::Route
- Chef::Exceptions::SearchIndex
- Chef::Exceptions::Service
- Chef::Exceptions::ShellCommandFailed
- Chef::Exceptions::SolrConnectionError
- Chef::Exceptions::UnresolvableGitReference
- Chef::Exceptions::UnsupportedAction
- Chef::Exceptions::User
- Chef::Exceptions::UserIDNotFound
- Chef::Exceptions::ValidationFailed
- Chef::Exceptions::Win32APIError
- Chef::Exceptions::Win32APIFunctionNotImplemented
- Chef::FileAccessControl
- Chef::FileAccessControl::Unix
- Chef::FileAccessControl::Windows
- Chef::FileCache
- Chef::Formatters
- Chef::Formatters::APIErrorFormatting
- Chef::Formatters::Base
- Chef::Formatters::Doc
- Chef::Formatters::ErrorDescription
- Chef::Formatters::ErrorInspectors
- Chef::Formatters::ErrorInspectors::CompileErrorInspector
- Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector
- Chef::Formatters::ErrorInspectors::CookbookSyncErrorInspector
- Chef::Formatters::ErrorInspectors::NodeLoadErrorInspector
- Chef::Formatters::ErrorInspectors::RegistrationErrorInspector
- Chef::Formatters::ErrorInspectors::ResourceFailureInspector
- Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector
- Chef::Formatters::ErrorMapper
- Chef::Formatters::Minimal
- Chef::Formatters::NullFormatter
- Chef::Formatters::Outputter
- Chef::Formatters::UnknownFormatter
- Chef::Handler
- Chef::Handler::ErrorReport
- Chef::Handler::JsonFile
- Chef::IndexQueue
- Chef::IndexQueue::AmqpClient
- Chef::IndexQueue::Consumer
- Chef::IndexQueue::Consumer::ClassMethods
- Chef::IndexQueue::Indexable
- Chef::IndexQueue::Indexable::ClassMethods
- Chef::JSONCompat
- Chef::Knife
- Chef::Knife::Bootstrap
- Chef::Knife::ClientBulkDelete
- Chef::Knife::ClientCreate
- Chef::Knife::ClientDelete
- Chef::Knife::ClientEdit
- Chef::Knife::ClientList
- Chef::Knife::ClientReregister
- Chef::Knife::ClientShow
- Chef::Knife::Configure
- Chef::Knife::ConfigureClient
- Chef::Knife::CookbookBulkDelete
- Chef::Knife::CookbookCreate
- Chef::Knife::CookbookDelete
- Chef::Knife::CookbookDownload
- Chef::Knife::CookbookList
- Chef::Knife::CookbookMetadata
- Chef::Knife::CookbookMetadataFromFile
- Chef::Knife::CookbookSCMRepo
- Chef::Knife::CookbookShow
- Chef::Knife::CookbookSiteDownload
- Chef::Knife::CookbookSiteInstall
- Chef::Knife::CookbookSiteList
- Chef::Knife::CookbookSiteSearch
- Chef::Knife::CookbookSiteShare
- Chef::Knife::CookbookSiteShow
- Chef::Knife::CookbookSiteUnshare
- Chef::Knife::CookbookSiteVendor
- Chef::Knife::CookbookTest
- Chef::Knife::CookbookUpload
- Chef::Knife::Core
- Chef::Knife::Core::BootstrapContext
- Chef::Knife::Core::GenericPresenter
- Chef::Knife::Core::NodeFormattingOptions
- Chef::Knife::Core::NodePresenter
- Chef::Knife::Core::ObjectLoader
- Chef::Knife::Core::ObjectLoader::ObjectType
- Chef::Knife::Core::TextFormatter
- Chef::Knife::DataBagCreate
- Chef::Knife::DataBagDelete
- Chef::Knife::DataBagEdit
- Chef::Knife::DataBagFromFile
- Chef::Knife::DataBagList
- Chef::Knife::DataBagShow
- Chef::Knife::EnvironmentCreate
- Chef::Knife::EnvironmentDelete
- Chef::Knife::EnvironmentEdit
- Chef::Knife::EnvironmentFromFile
- Chef::Knife::EnvironmentList
- Chef::Knife::EnvironmentShow
- Chef::Knife::Exec
- Chef::Knife::Help
- Chef::Knife::IndexRebuild
- Chef::Knife::NodeBulkDelete
- Chef::Knife::NodeCreate
- Chef::Knife::NodeDelete
- Chef::Knife::NodeEdit
- Chef::Knife::NodeEditor
- Chef::Knife::NodeFromFile
- Chef::Knife::NodeList
- Chef::Knife::NodeRunListAdd
- Chef::Knife::NodeRunListRemove
- Chef::Knife::NodeShow
- Chef::Knife::RecipeList
- Chef::Knife::RoleBulkDelete
- Chef::Knife::RoleCreate
- Chef::Knife::RoleDelete
- Chef::Knife::RoleEdit
- Chef::Knife::RoleFromFile
- Chef::Knife::RoleList
- Chef::Knife::RoleShow
- Chef::Knife::Search
- Chef::Knife::Ssh
- Chef::Knife::Status
- Chef::Knife::SubcommandLoader
- Chef::Knife::TagCreate
- Chef::Knife::TagDelete
- Chef::Knife::TagList
- Chef::Knife::UI
- Chef::Log
- Chef::Log::Formatter
- Chef::MinimalCookbookVersion
- Chef::Mixin
- Chef::Mixin::CheckHelper
- Chef::Mixin::Checksum
- Chef::Mixin::Command
- Chef::Mixin::Command::Unix
- Chef::Mixin::Command::Windows
- Chef::Mixin::ConvertToClassName
- Chef::Mixin::CreatePath
- Chef::Mixin::DeepMerge
- Chef::Mixin::DeepMerge::InvalidParameter
- Chef::Mixin::Deprecation
- Chef::Mixin::Deprecation::DeprecatedInstanceVariable
- Chef::Mixin::Deprecation::DeprecatedObjectProxyBase
- Chef::Mixin::EnforceOwnershipAndPermissions
- Chef::Mixin::FileClass
- Chef::Mixin::FromFile
- Chef::Mixin::GetSourceFromPackage
- Chef::Mixin::Language
- Chef::Mixin::Language::PlatformDependentValue
- Chef::Mixin::Language::PlatformFamilyDependentValue
- Chef::Mixin::LanguageIncludeAttribute
- Chef::Mixin::LanguageIncludeRecipe
- Chef::Mixin::ParamsValidate
- Chef::Mixin::PathSanity
- Chef::Mixin::RecipeDefinitionDSLCore
- Chef::Mixin::Securable
- Chef::Mixin::ShellOut
- Chef::Mixin::Template
- Chef::Mixin::Template::ChefContext
- Chef::Mixin::Template::TemplateError
- Chef::Mixin::WhyRun
- Chef::Mixin::WhyRun::ConvergeActions
- Chef::Mixin::WhyRun::ResourceRequirements
- Chef::Mixin::WhyRun::ResourceRequirements::Assertion
- Chef::Mixin::WhyRun::ResourceRequirements::Assertion::AssertionFailure
- Chef::Mixin::XMLEscape
- Chef::Mixin::XMLEscape::FastXS
- Chef::Mixin::XMLEscape::PureRuby
- Chef::Node
- Chef::Node::Attribute
- Chef::OpenIDRegistration
- Chef::Platform
- Chef::Provider
- Chef::Provider::Breakpoint
- Chef::Provider::CookbookFile
- Chef::Provider::Cron
- Chef::Provider::Cron::Solaris
- Chef::Provider::Deploy
- Chef::Provider::Deploy::Revision
- Chef::Provider::Deploy::Timestamped
- Chef::Provider::Directory
- Chef::Provider::Env
- Chef::Provider::Env::Windows
- Chef::Provider::ErlCall
- Chef::Provider::Execute
- Chef::Provider::File
- Chef::Provider::Git
- Chef::Provider::Group
- Chef::Provider::Group::Aix
- Chef::Provider::Group::Dscl
- Chef::Provider::Group::Gpasswd
- Chef::Provider::Group::Groupadd
- Chef::Provider::Group::Groupmod
- Chef::Provider::Group::Pw
- Chef::Provider::Group::Suse
- Chef::Provider::Group::Usermod
- Chef::Provider::Group::Windows
- Chef::Provider::HttpRequest
- Chef::Provider::Ifconfig
- Chef::Provider::Link
- Chef::Provider::Log
- Chef::Provider::Log::ChefLog
- Chef::Provider::Mdadm
- Chef::Provider::Mount
- Chef::Provider::Mount::Mount
- Chef::Provider::Mount::Windows
- Chef::Provider::Ohai
- Chef::Provider::Package
- Chef::Provider::Package::Apt
- Chef::Provider::Package::Dpkg
- Chef::Provider::Package::EasyInstall
- Chef::Provider::Package::Freebsd
- Chef::Provider::Package::Ips
- Chef::Provider::Package::Macports
- Chef::Provider::Package::Pacman
- Chef::Provider::Package::Portage
- Chef::Provider::Package::Rpm
- Chef::Provider::Package::Rubygems
- Chef::Provider::Package::Rubygems::AlternateGemEnvironment
- Chef::Provider::Package::Rubygems::CurrentGemEnvironment
- Chef::Provider::Package::Rubygems::GemEnvironment
- Chef::Provider::Package::SmartOS
- Chef::Provider::Package::Solaris
- Chef::Provider::Package::Yum
- Chef::Provider::Package::Yum::RPMDb
- Chef::Provider::Package::Yum::RPMDbPackage
- Chef::Provider::Package::Yum::RPMDependency
- Chef::Provider::Package::Yum::RPMPackage
- Chef::Provider::Package::Yum::RPMProvide
- Chef::Provider::Package::Yum::RPMRequire
- Chef::Provider::Package::Yum::RPMUtils
- Chef::Provider::Package::Yum::RPMVersion
- Chef::Provider::Package::Yum::YumCache
- Chef::Provider::Package::Zypper
- Chef::Provider::RemoteDirectory
- Chef::Provider::RemoteFile
- Chef::Provider::ResourceUpdate
- Chef::Provider::Route
- Chef::Provider::RubyBlock
- Chef::Provider::Script
- Chef::Provider::Service
- Chef::Provider::Service::Arch
- Chef::Provider::Service::Debian
- Chef::Provider::Service::Freebsd
- Chef::Provider::Service::Gentoo
- Chef::Provider::Service::Init
- Chef::Provider::Service::Insserv
- Chef::Provider::Service::Invokercd
- Chef::Provider::Service::Macosx
- Chef::Provider::Service::Redhat
- Chef::Provider::Service::Simple
- Chef::Provider::Service::Solaris
- Chef::Provider::Service::Systemd
- Chef::Provider::Service::Upstart
- Chef::Provider::Service::Windows
- Chef::Provider::Subversion
- Chef::Provider::Template
- Chef::Provider::User
- Chef::Provider::User::Dscl
- Chef::Provider::User::Pw
- Chef::Provider::User::Useradd
- Chef::Provider::User::Windows
- Chef::REST
- Chef::REST::AuthCredentials
- Chef::REST::CookieJar
- Chef::REST::NoopInflater
- Chef::REST::RESTRequest
- Chef::Recipe
- Chef::ReservedNames
- Chef::ReservedNames::Win32
- Chef::ReservedNames::Win32::API
- Chef::ReservedNames::Win32::API::Error
- Chef::ReservedNames::Win32::API::File
- Chef::ReservedNames::Win32::API::File::BY_HANDLE_FILE_INFORMATION
- Chef::ReservedNames::Win32::API::File::FILETIME
- Chef::ReservedNames::Win32::API::File::REPARSE_DATA_BUFFER
- Chef::ReservedNames::Win32::API::File::REPARSE_DATA_BUFFER_GENERIC
- Chef::ReservedNames::Win32::API::File::REPARSE_DATA_BUFFER_MOUNT_POINT
- Chef::ReservedNames::Win32::API::File::REPARSE_DATA_BUFFER_SYMBOLIC_LINK
- Chef::ReservedNames::Win32::API::File::REPARSE_DATA_BUFFER_UNION
- Chef::ReservedNames::Win32::API::File::SECURITY_ATTRIBUTES
- Chef::ReservedNames::Win32::API::File::WIN32_FIND_DATA
- Chef::ReservedNames::Win32::API::Macros
- Chef::ReservedNames::Win32::API::Memory
- Chef::ReservedNames::Win32::API::PSAPI
- Chef::ReservedNames::Win32::API::PSAPI::PROCESS_MEMORY_COUNTERS
- Chef::ReservedNames::Win32::API::Process
- Chef::ReservedNames::Win32::API::Security
- Chef::ReservedNames::Win32::API::Security::ACE_HEADER
- Chef::ReservedNames::Win32::API::Security::ACE_WITH_MASK_AND_SID
- Chef::ReservedNames::Win32::API::Security::ACLStruct
- Chef::ReservedNames::Win32::API::Security::LUID
- Chef::ReservedNames::Win32::API::Security::LUID_AND_ATTRIBUTES
- Chef::ReservedNames::Win32::API::Security::TOKEN_PRIVILEGES
- Chef::ReservedNames::Win32::API::System
- Chef::ReservedNames::Win32::API::System::OSVERSIONINFOEX
- Chef::ReservedNames::Win32::API::Unicode
- Chef::ReservedNames::Win32::Error
- Chef::ReservedNames::Win32::File
- Chef::ReservedNames::Win32::File::Info
- Chef::ReservedNames::Win32::Handle
- Chef::ReservedNames::Win32::Memory
- Chef::ReservedNames::Win32::Process
- Chef::ReservedNames::Win32::Security
- Chef::ReservedNames::Win32::Security::ACE
- Chef::ReservedNames::Win32::Security::ACL
- Chef::ReservedNames::Win32::Security::SID
- Chef::ReservedNames::Win32::Security::SecurableObject
- Chef::ReservedNames::Win32::Security::SecurityDescriptor
- Chef::ReservedNames::Win32::Security::Token
- Chef::ReservedNames::Win32::Unicode
- Chef::ReservedNames::Win32::Version
- Chef::Resource
- Chef::Resource::AptPackage
- Chef::Resource::Bash
- Chef::Resource::Breakpoint
- Chef::Resource::ChefGem
- Chef::Resource::Conditional
- Chef::Resource::CookbookFile
- Chef::Resource::Cron
- Chef::Resource::Csh
- Chef::Resource::Deploy
- Chef::Resource::DeployBranch
- Chef::Resource::DeployRevision
- Chef::Resource::Directory
- Chef::Resource::DpkgPackage
- Chef::Resource::EasyInstallPackage
- Chef::Resource::Env
- Chef::Resource::ErlCall
- Chef::Resource::Execute
- Chef::Resource::File
- Chef::Resource::FreebsdPackage
- Chef::Resource::GemPackage
- Chef::Resource::Git
- Chef::Resource::Group
- Chef::Resource::HttpRequest
- Chef::Resource::Ifconfig
- Chef::Resource::IpsPackage
- Chef::Resource::Link
- Chef::Resource::Log
- Chef::Resource::MacportsPackage
- Chef::Resource::Mdadm
- Chef::Resource::Mount
- Chef::Resource::Notification
- Chef::Resource::Ohai
- Chef::Resource::Package
- Chef::Resource::PacmanPackage
- Chef::Resource::Perl
- Chef::Resource::PlatformMap
- Chef::Resource::PortagePackage
- Chef::Resource::Python
- Chef::Resource::RemoteDirectory
- Chef::Resource::RemoteFile
- Chef::Resource::Route
- Chef::Resource::RpmPackage
- Chef::Resource::Ruby
- Chef::Resource::RubyBlock
- Chef::Resource::Scm
- Chef::Resource::Script
- Chef::Resource::Service
- Chef::Resource::SmartOSPackage
- Chef::Resource::SolarisPackage
- Chef::Resource::Subversion
- Chef::Resource::Template
- Chef::Resource::TimestampedDeploy
- Chef::Resource::User
- Chef::Resource::YumPackage
- Chef::ResourceCollection
- Chef::ResourceCollection::StepableIterator
- Chef::ResourceDefinition
- Chef::ResourceDefinitionList
- Chef::ResourceReporter
- Chef::ResourceReporter::ResourceReport
- Chef::Role
- Chef::RunContext
- Chef::RunList
- Chef::RunList::RunListExpansion
- Chef::RunList::RunListExpansionFromAPI
- Chef::RunList::RunListExpansionFromCouchDB
- Chef::RunList::RunListExpansionFromDisk
- Chef::RunList::RunListItem
- Chef::RunList::VersionedRecipeList
- Chef::RunStatus
- Chef::Runner
- Chef::Sandbox
- Chef::ScanAccessControl
- Chef::Search
- Chef::Search::Query
- Chef::ShellOut
- Chef::SolrQuery
- Chef::SolrQuery::QueryTransform
- Chef::SolrQuery::SolrHTTPRequest
- Chef::StreamingCookbookUploader
- Chef::StreamingCookbookUploader::MultipartStream
- Chef::StreamingCookbookUploader::StreamPart
- Chef::StreamingCookbookUploader::StringPart
- Chef::Util
- Chef::Util::FileEdit
- Chef::Util::Windows
- Chef::Util::Windows::NetGroup
- Chef::Util::Windows::NetUse
- Chef::Util::Windows::NetUser
- Chef::Util::Windows::Volume
- Chef::Version
- Chef::VersionConstraint
- Chef::WebUIUser
- Lucene
- Lucene::AndOperator
- Lucene::BinaryOp
- Lucene::Body
- Lucene::BoostOp
- Lucene::ExclFieldRange
- Lucene::Field
- Lucene::FieldName
- Lucene::FieldRange
- Lucene::FuzzyOp
- Lucene::FuzzyParam
- Lucene::Group
- Lucene::InclFieldRange
- Lucene::NotOperator
- Lucene::OrOperator
- Lucene::Phrase
- Lucene::ProhibitedOperator
- Lucene::RangeValue
- Lucene::RequiredOperator
- Lucene::Term
- Lucene::UnaryOp
- Shef
- Shef::ClientSession
- Shef::DoppelGangerClient
- Shef::DoppelGangerSession
- Shef::Extensions
- Shef::Extensions::FalseClass
- Shef::Extensions::ObjectCoreExtensions
- Shef::Extensions::String
- Shef::Extensions::Symbol
- Shef::Extensions::TrueClass
- Shef::ModelWrapper
- Shef::NamedDataBagWrapper
- Shef::Options
- Shef::ShefREST
- Shef::ShefSession
- Shef::SoloSession
- Shef::StandAloneSession
- Net
- Net::HTTPError
- Net::HTTPFatalError
- Net::HTTPRetriableError
- Net::HTTPServerException
- Moneta
- Moneta::BasicFile
- Moneta::Defaults
- FFI
- FFI::Pointer
- FileUtils
- FileUtils::Entry_
- ChefNetHTTPExceptionExtensions
- Dir
- FalseClass
- Mash
- Numeric
- Object
- Regexp
- String
- Symbol
- TrueClass

No matching classes.

# Chef::Handler

The base class for an Exception or Notification Handler. Create your own handler by subclassing Chef::Handler. When a Chef run fails with an uncaught Exception, Chef will set the `run_status` on your handler and call `report`

### Example:

    require 'net/smtp'

    module MyOrg
      class OhNoes < Chef::Handler

        def report
          # Create the email message
          message  = "From: Your Name <your@mail.address>\n"
          message << "To: Destination Address <someone@example.com>\n"
          message << "Subject: Chef Run Failure\n"
          message << "Date: #{Time.now.rfc2822}\n\n"

          # The Node is available as +node+
          message << "Chef run failed on #{node.name}\n"
          # +run_status+ is a value object with all of the run status data
          message << "#{run_status.formatted_exception}\n"
          # Join the backtrace lines. Coerce to an array just in case.
          message << Array(backtrace).join("\n")

          # Send the email
          Net::SMTP.start('your.smtp.server', 25) do |smtp|
            smtp.send_message message, 'from@address', 'to@address'
          end
        end

      end
    end

### Attributes

run_status[R]

The Chef::RunStatus object containing data about the Chef run.

### Public Class Methods

exception_handlers() click to toggle source

The list of currently configured exception handlers

    # File lib/chef/handler.rb, line 107
    def self.exception_handlers
      Array(Chef::Config[:exception_handlers])
    end

report_handlers() click to toggle source

The list of currently configured report handlers

    # File lib/chef/handler.rb, line 82
    def self.report_handlers
      Array(Chef::Config[:report_handlers])
    end

run_exception_handlers(run_status) click to toggle source

Run the exception handlers. Usually will be called by a notification from Chef::Client when the run fails.

    # File lib/chef/handler.rb, line 113
    def self.run_exception_handlers(run_status)
      events = run_status.events
      events.handlers_start(exception_handlers.size)
      Chef::Log.error("Running exception handlers")
      exception_handlers.each do |handler|
        handler.run_report_safely(run_status)
        events.handler_executed(handler)
      end
      events.handlers_completed
      Chef::Log.error("Exception handlers complete")
    end

run_report_handlers(run_status) click to toggle source

Run the report handlers. This will usually be called by a notification from Chef::Client

    # File lib/chef/handler.rb, line 88
    def self.run_report_handlers(run_status)
      events = run_status.events
      events.handlers_start(report_handlers.size)
      Chef::Log.info("Running report handlers")
      report_handlers.each do |handler|
        handler.run_report_safely(run_status)
        events.handler_executed(handler)
      end
      events.handlers_completed
      Chef::Log.info("Report handlers complete")
    end

run_start_handlers(run_status) click to toggle source

Run the start handlers. This will usually be called by a notification from Chef::Client

    # File lib/chef/handler.rb, line 67
    def self.run_start_handlers(run_status)
      Chef::Log.info("Running start handlers")
      start_handlers.each do |handler|
        handler.run_report_safely(run_status)
      end
      Chef::Log.info("Start handlers complete.")
    end

start_handlers() click to toggle source

The list of currently configured start handlers

    # File lib/chef/handler.rb, line 61
    def self.start_handlers
      Array(Chef::Config[:start_handlers])
    end

### Public Instance Methods

all_resources click to toggle source

An Array containing all resources in the chef run's resource_collection

    # File lib/chef/handler.rb, line 183
    def_delegator :@run_status, :all_resources

backtrace click to toggle source

The backtrace captured by the uncaught exception that terminated the chef run, or nil if the run completed successfully

    # File lib/chef/handler.rb, line 171
    def_delegator :@run_status, :backtrace

data() click to toggle source

Return the Hash representation of the run_status

    # File lib/chef/handler.rb, line 230
    def data
      @run_status.to_hash
    end

elapsed_time click to toggle source

The time elapsed between the start and finish of the chef run

    # File lib/chef/handler.rb, line 151
    def_delegator :@run_status, :elapsed_time

end_time click to toggle source

The time the chef run ended

    # File lib/chef/handler.rb, line 145
    def_delegator :@run_status, :end_time

exception click to toggle source

The uncaught Exception that terminated the chef run, or nil if the run completed successfully

    # File lib/chef/handler.rb, line 164
    def_delegator :@run_status, :exception

failed? click to toggle source

Did the chef run fail? True if the chef run raised an uncaught exception

    # File lib/chef/handler.rb, line 202
    def_delegator :@run_status, :failed?

node click to toggle source

The Chef::Node for this client run

    # File lib/chef/handler.rb, line 177
    def_delegator :@run_status, :node

report() click to toggle source

The main entry point for report handling. Subclasses should override this method with their own report handling logic.

    # File lib/chef/handler.rb, line 206
    def report
    end

run_context click to toggle source

The Chef::RunContext object used by the chef run

    # File lib/chef/handler.rb, line 157
    def_delegator :@run_status, :run_context

run_report_safely(run_status) click to toggle source

Runs the report handler, rescuing and logging any errors it may cause. This ensures that all handlers get a chance to run even if one fails. This method should not be overridden by subclasses unless you know what you're doing.

    # File lib/chef/handler.rb, line 213
    def run_report_safely(run_status)
      run_report_unsafe(run_status)
    rescue Exception => e
      Chef::Log.error("Report handler #{self.class.name} raised #{e.inspect}")
      Array(e.backtrace).each { |line| Chef::Log.error(line) }
    ensure
      @run_status = nil
    end

run_report_unsafe(run_status) click to toggle source

Runs the report handler without any error handling. This method should not be used directly except in testing.

    # File lib/chef/handler.rb, line 224
    def run_report_unsafe(run_status)
      @run_status = run_status
      report
    end

start_time click to toggle source

The time the chef run started

    # File lib/chef/handler.rb, line 139
    def_delegator :@run_status, :start_time

success? click to toggle source

Was the chef run successful? True if the chef run did not raise an uncaught exception

    # File lib/chef/handler.rb, line 196
    def_delegator :@run_status, :success?

updated_resources click to toggle source

An Array containing all resources that were updated during the chef run

    # File lib/chef/handler.rb, line 189
    def_delegator :@run_status, :updated_resources

[Validate]

Generated with the Darkfish Rdoc Generator 2.