Class: Y2Issues::Issue

Inherits:
Object
  • Object
show all
Includes:
Yast::I18n
Defined in:
library/general/src/lib/y2issues/issue.rb

Overview

Represents a problem detected by YaST.

This class represents a generic error. Other classes can inherit from this one to add more specific information. See InvalidValue as an example.

Examples:

Create a new error

Issue.new("Could not read network configuration", severity: :error)

Create an error from an specific location

Issue.new(
  "Could not read the routing table",
  location: "file:/etc/sysconfig/ifroute-eth0",
  severity: :warn
)

Direct Known Subclasses

InvalidValue

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, location: nil, severity: :warn) ⇒ Issue

Returns a new instance of Issue.

Parameters:

  • message (String)

    User-oriented message describing the problem

  • location (String, nil) (defaults to: nil)

    Where the error is located. Use a URI or a string to represent the error location. Use 'nil' if it does not exist an specific location.

  • severity (Symbol) (defaults to: :warn)

    warning (:warn) or error (:error)



53
54
55
56
57
# File 'library/general/src/lib/y2issues/issue.rb', line 53

def initialize(message, location: nil, severity: :warn)
  @message = message
  @location = location.is_a?(String) ? Location.parse(location) : location
  @severity = severity
end

Instance Attribute Details

#locationLocation? (readonly)

Returns Where the error is located.

Returns:

  • (Location, nil)

    Where the error is located.



42
43
44
# File 'library/general/src/lib/y2issues/issue.rb', line 42

def location
  @location
end

#messageString (readonly)

Returns Error message.

Returns:

  • (String)

    Error message



44
45
46
# File 'library/general/src/lib/y2issues/issue.rb', line 44

def message
  @message
end

#severitySymbol (readonly)

Returns Error severity (:warn, :error).

Returns:

  • (Symbol)

    Error severity (:warn, :error)



46
47
48
# File 'library/general/src/lib/y2issues/issue.rb', line 46

def severity
  @severity
end

Instance Method Details

#error?Boolean Also known as: fatal?

Determines whether the issue is an error

Returns:

  • (Boolean)


62
63
64
# File 'library/general/src/lib/y2issues/issue.rb', line 62

def error?
  @severity == :error
end