class Kramdown::PlantUml::PlantUmlError

PlantUML Error

Public Class Methods

new(result) click to toggle source
Calls superclass method
# File lib/kramdown-plantuml/plantuml_error.rb, line 9
def initialize(result)
  raise ArgumentError, 'result cannot be nil' if result.nil?
  raise ArgumentError, "result must be a #{PlantUmlResult}" unless result.is_a?(PlantUmlResult)

  super create_message(result)
end

Private Instance Methods

create_message(result) click to toggle source
# File lib/kramdown-plantuml/plantuml_error.rb, line 18
      def create_message(result)
        header = header(result).gsub("\n", ' ').strip
        plantuml = plantuml(result)
        result = result(result)
        message = <<~MESSAGE
          #{header}

          #{plantuml}

          #{result}
        MESSAGE

        message.strip
      end
header(result) click to toggle source
# File lib/kramdown-plantuml/plantuml_error.rb, line 33
      def header(result)
        if theme_not_found?(result) && !result.diagram.nil? && !result.diagram.theme.nil?
          return <<~HEADER
            Conversion of the following PlantUML result failed because the
            theme '#{result.diagram.theme.name}' can't be found in the directory
            '#{result.diagram.theme.directory}':
          HEADER
        end

        'Conversion of the following PlantUML result failed:'
      end
plantuml(result) click to toggle source
# File lib/kramdown-plantuml/plantuml_error.rb, line 52
def plantuml(result)
  return nil if result.nil? || result.diagram.nil?

  result.diagram.plantuml
end
result(result) click to toggle source
# File lib/kramdown-plantuml/plantuml_error.rb, line 58
      def result(result)
        return nil if result.nil?

        <<~RESULT
          The error received from PlantUML was:

          Exit code: #{result.exitcode}
          #{result.stderr}
        RESULT
      end
theme_not_found?(result) click to toggle source
# File lib/kramdown-plantuml/plantuml_error.rb, line 45
def theme_not_found?(result)
  !result.nil? \
  && !result.stderr.nil? \
  && result.stderr.include?('NullPointerException') \
  && result.stderr.include?('getTheme')
end