Class: Vellum::VellumSdkError

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/types/vellum_sdk_error.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message:, raw_data: OMIT, code:, additional_properties: nil) ⇒ Vellum::VellumSdkError

Parameters:



28
29
30
31
32
33
34
35
36
# File 'lib/vellum_ai/types/vellum_sdk_error.rb', line 28

def initialize(message:, raw_data: OMIT, code:, additional_properties: nil)
  @message = message
  @raw_data = raw_data if raw_data != OMIT
  @code = code
  @additional_properties = additional_properties
  @_field_set = { "message": message, "raw_data": raw_data, "code": code }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



16
17
18
# File 'lib/vellum_ai/types/vellum_sdk_error.rb', line 16

def additional_properties
  @additional_properties
end

#code ⇒ Vellum::VellumSdkErrorCodeEnum (readonly)



14
15
16
# File 'lib/vellum_ai/types/vellum_sdk_error.rb', line 14

def code
  @code
end

#message ⇒ String (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/vellum_ai/types/vellum_sdk_error.rb', line 10

def message
  @message
end

#raw_data ⇒ Vellum::VellumSdkErrorRawData (readonly)



12
13
14
# File 'lib/vellum_ai/types/vellum_sdk_error.rb', line 12

def raw_data
  @raw_data
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::VellumSdkError

Parameters:

  • json_object (String)

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/vellum_ai/types/vellum_sdk_error.rb', line 41

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  message = parsed_json["message"]
  unless parsed_json["raw_data"].nil?
    raw_data = parsed_json["raw_data"].to_json
    raw_data = Vellum::VellumSdkErrorRawData.from_json(json_object: raw_data)
  else
    raw_data = nil
  end
  code = parsed_json["code"]
  new(
    message: message,
    raw_data: raw_data,
    code: code,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


71
72
73
74
75
# File 'lib/vellum_ai/types/vellum_sdk_error.rb', line 71

def self.validate_raw(obj:)
  obj.message.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.")
  obj.raw_data.nil? || Vellum::VellumSdkErrorRawData.validate_raw(obj: obj.raw_data)
  obj.code.is_a?(Vellum::VellumSdkErrorCodeEnum) != false || raise("Passed value for field obj.code is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


62
63
64
# File 'lib/vellum_ai/types/vellum_sdk_error.rb', line 62

def to_json
  @_field_set&.to_json
end