Class: Newshound::Exceptions::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/newshound/exceptions/base.rb

Overview

Base class for exception source adapters Each adapter is responsible for:

  1. Fetching recent exceptions from its specific exception tracking system

  2. Formatting exception data for reports and banners

Subclasses must implement:

  • #recent(time_range:, limit:) - Returns a collection of exception records

  • #format_for_report(exception) - Formats a single exception for Slack/report display

  • #format_for_banner(exception) - Formats a single exception for banner UI

Direct Known Subclasses

ExceptionTrack, SolidErrors

Instance Method Summary collapse

Instance Method Details

#format_for_banner(exception) ⇒ Hash

Formats an exception for banner UI display

Parameters:

  • exception (Object)

    Exception record from the tracking system

Returns:

  • (Hash)

    Hash with keys: :title, :message, :location, :time

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/newshound/exceptions/base.rb', line 35

def format_for_banner(exception)
  raise NotImplementedError, "#{self.class} must implement #format_for_banner"
end

#format_for_report(exception, number) ⇒ String

Formats an exception for report/Slack display

Parameters:

  • exception (Object)

    Exception record from the tracking system

  • number (Integer)

    Position number in the list

Returns:

  • (String)

    Formatted markdown text for display

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/newshound/exceptions/base.rb', line 27

def format_for_report(exception, number)
  raise NotImplementedError, "#{self.class} must implement #format_for_report"
end

#recent(time_range:, limit:) ⇒ Array

Fetches recent exceptions from the exception tracking system

Parameters:

  • time_range (ActiveSupport::Duration)

    Time duration to look back (e.g., 24.hours)

  • limit (Integer)

    Maximum number of exceptions to return

Returns:

  • (Array)

    Collection of exception records

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/newshound/exceptions/base.rb', line 18

def recent(time_range:, limit:)
  raise NotImplementedError, "#{self.class} must implement #recent"
end