Class: DepShield::Deprecation

Inherits:
Object
  • Object
show all
Defined in:
lib/dep_shield/deprecation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, message:, callstack:) ⇒ Deprecation

Returns a new instance of Deprecation.



7
8
9
10
11
# File 'lib/dep_shield/deprecation.rb', line 7

def initialize(name:, message:, callstack:)
  @name = name
  @stack = cleaner.clean(callstack.map(&:to_s))
  @error = DepShield::Error.new("#{name}:\n#{message}", stack)
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



5
6
7
# File 'lib/dep_shield/deprecation.rb', line 5

def error
  @error
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/dep_shield/deprecation.rb', line 5

def name
  @name
end

#stackObject (readonly)

Returns the value of attribute stack.



5
6
7
# File 'lib/dep_shield/deprecation.rb', line 5

def stack
  @stack
end

Instance Method Details

#raise_or_capture!Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dep_shield/deprecation.rb', line 13

def raise_or_capture!
  Rails.logger.warn("NITRO DEPRECATION WARNING") { "#{error}\n#{stack}" }
  return if DepShield.todos.allowed?(name, stack)

  raise error unless NitroConfig.get("nitro_errors/capture_deprecation")

  Sentry.capture_exception(
    error,
    tags: { environment: Rails.env, deprecation_error: name }
  )
end