-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #737 from cyberark/fix_policy_load_exception
Fix policy load exception on host factory with no layers
- Loading branch information
Showing
5 changed files
with
79 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module Exceptions | ||
class InvalidPolicyObject < RuntimeError | ||
attr_reader :id, :account, :kind, :identifier | ||
|
||
def initialize id, message: nil | ||
super message || self.class.build_message(id) | ||
|
||
@id = id | ||
@account, @kind, @identifier = self.class.parse_id(id) | ||
end | ||
|
||
class << self | ||
def parse_id id | ||
id.split(':', 3) | ||
end | ||
|
||
def build_message id | ||
account, kind, id = parse_id(id) | ||
kind ||= 'unknown kind' | ||
"The policy definition for #{kind.capitalize} '#{id}' is not valid" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters