mirror of
https://github.com/zammad/zammad
synced 2026-05-24 09:48:36 +00:00
Co-authored-by: Benjamin Scharf <bs@zammad.com> Co-authored-by: Dominik Klein <dk@zammad.com> Co-authored-by: Dusan Vuckovic <dv@zammad.com> Co-authored-by: Florian Liebe <fl@zammad.com> Co-authored-by: Mantas Masalskis <mm@zammad.com> Co-authored-by: Martin Gruner <mg@zammad.com> Co-authored-by: Tobias Schäfer <ts@zammad.com>
39 lines
810 B
Ruby
39 lines
810 B
Ruby
# Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
|
|
|
|
class MicrosoftGraph
|
|
class ApiError < StandardError
|
|
attr_reader :error
|
|
|
|
def initialize(error_hash)
|
|
@error = error_hash.with_indifferent_access
|
|
|
|
super()
|
|
end
|
|
|
|
def error_code
|
|
error[:code] || 'no error code present'
|
|
end
|
|
|
|
def error_message
|
|
error[:message] || 'An unknown error occurred.' # rubocop:disable Zammad/DetectTranslatableString
|
|
end
|
|
|
|
def request_id
|
|
error.dig(:innerError, :'request-id')
|
|
end
|
|
|
|
def message
|
|
output = "#{error_message} (#{error_code})"
|
|
|
|
if request_id
|
|
output += "\nMicrosoft Graph API Request ID: #{request_id}"
|
|
end
|
|
|
|
output
|
|
end
|
|
|
|
def inspect
|
|
"#<#{self.class.name}: #{message.dump}>"
|
|
end
|
|
end
|
|
end
|