# # Copyright (c) 2009-2013 NetApp Inc. # All rights reserved. # ## @summary Provide an exception class that is a subclass of ## NATE::BaseException that will be thrown when ## cleanup fails. ## ## @author chethanm@netapp.com, dl-nacl-dev@netapp.com ## @status Shared ## @pod here =head1 NAME NACL::Exceptions::CleanupFailed =head1 DESCRIPTION This exception is thrown when cleanup subsystem fails to run cleanup on any element. In addition to the attributes that exception objects generally contain, this exception also contains an additional attribute called C. This is an array reference, which will hold all the objects for which the cleanup failed along with the exception object for each of those failures. =head1 ATTRIBUTES =head2 cleanup_failed_for This attribute is a array-reference of hash references, which will hold primary keys and the exception object for all the failures encountered during cleanup. Structure of the reported data structure would be, 'cleanup_failed_for => [ {'primary_keys' => $hashref, 'exception' => $exception_obj}, ...] =head1 EXAMPLE use NACL::Exceptions::CleanupFailed qw(:try); use NACL::Cleanup; use Data::Dumper; use NACL::STask::Volume; my $cleanup = NACL::Cleanup->new(); my $ci = NACL::C::Node->find(); try { # Create 6 volumes with cleanup enabled foreach ( 1 .. 5 ) { NACL::STask::Volume->create( 'command_interface' => $ci, 'nacltask_to_cleanup' => 1 ); } # Perform cleanup $cleanup->run(); } catch NACL::Exceptions::CleanupFailed with { my $exception = shift; my $failures = $exception->cleanup_failed_for(); foreach my $failure ( @{$failures} ) { my $class = $failure->{'class'}; my $primary_keys = $failure->{'primary_keys'}; my $exception = $failure->{'exception'}; $Log->comment("Cleanup failed for: \n"); $Log->comment("Class: $class"); $Log->comment("Primary Keys: " . Dumper($primary_keys); $Log->comment("Exception : " . Dumper($exception); } }; =cut package NACL::Exceptions::CleanupFailed; use base qw(NATE::BaseException); use Class::MethodMaker [ array => 'cleanup_failed_for' ]; 1;