From 64d319d40fdb9bb50d30b59b3592f0dd5545d21c Mon Sep 17 00:00:00 2001 From: Rupak Ganguly Date: Tue, 30 Oct 2012 15:06:56 -0400 Subject: [PATCH] Allow the models to raise exception when there is insufficient access. --- lib/fog/hp/models/storage/shared_directories.rb | 6 ++++-- lib/fog/hp/models/storage/shared_file.rb | 3 ++- lib/fog/hp/models/storage/shared_files.rb | 9 ++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/fog/hp/models/storage/shared_directories.rb b/lib/fog/hp/models/storage/shared_directories.rb index 72d7df042..7df96e2a6 100644 --- a/lib/fog/hp/models/storage/shared_directories.rb +++ b/lib/fog/hp/models/storage/shared_directories.rb @@ -23,7 +23,8 @@ module Fog end shared_directory - rescue Fog::Storage::HP::NotFound, Fog::HP::Errors::Forbidden + # throws exception Fog::HP::Errors::Forbidden if insufficient access + rescue Fog::Storage::HP::NotFound nil end @@ -42,7 +43,8 @@ module Fog end shared_directory - rescue Fog::Storage::HP::NotFound, Fog::HP::Errors::Forbidden + # throws exception Fog::HP::Errors::Forbidden if insufficient access + rescue Fog::Storage::HP::NotFound nil end diff --git a/lib/fog/hp/models/storage/shared_file.rb b/lib/fog/hp/models/storage/shared_file.rb index 889502f82..c66b97e87 100644 --- a/lib/fog/hp/models/storage/shared_file.rb +++ b/lib/fog/hp/models/storage/shared_file.rb @@ -47,7 +47,8 @@ module Fog merge_attributes(data.headers) self.content_length = Fog::Storage.get_body_size(body) true - rescue Fog::Storage::HP::NotFound, Fog::HP::Errors::Forbidden + # throws exception Fog::HP::Errors::Forbidden if insufficient access + rescue Fog::Storage::HP::NotFound false end diff --git a/lib/fog/hp/models/storage/shared_files.rb b/lib/fog/hp/models/storage/shared_files.rb index 1b29ef80a..385bd7e2b 100644 --- a/lib/fog/hp/models/storage/shared_files.rb +++ b/lib/fog/hp/models/storage/shared_files.rb @@ -19,7 +19,8 @@ module Fog else nil end - rescue Fog::Storage::HP::NotFound, Fog::HP::Errors::Forbidden + # throws exception Fog::HP::Errors::Forbidden if insufficient access + rescue Fog::Storage::HP::NotFound nil end @@ -32,7 +33,8 @@ module Fog :key => key }) new(file_data) - rescue Fog::Storage::HP::NotFound, Fog::HP::Errors::Forbidden + # throws exception Fog::HP::Errors::Forbidden if insufficient access + rescue Fog::Storage::HP::NotFound nil end @@ -45,7 +47,8 @@ module Fog :key => key }) new(file_data) - rescue Fog::Storage::HP::NotFound, Fog::HP::Errors::Forbidden + # throws exception Fog::HP::Errors::Forbidden if insufficient access + rescue Fog::Storage::HP::NotFound nil end