# Exception: Haml::Error

Inherits:
  StandardError
  - Object
  - StandardError
  - Haml::Error
  show all

Defined in:
  lib/haml/error.rb

## Overview

An exception raised by Haml code.

## Direct Known Subclasses

SyntaxError

## Instance Attribute Summary collapse

- #line ⇒ Fixnum readonly

  The line of the template on which the error occurred.

## Class Method Summary collapse

- .message(key, *args)

## Instance Method Summary collapse

- #initialize(message = nil, line = nil) ⇒ Error constructor

  A new instance of Error.

## Constructor Details

### #initialize(message = nil, line = nil) ⇒ `Error`

Returns a new instance of Error.

Parameters:

- message (`String`) (defaults to: `nil`) —

  The error message

- line (`Fixnum`) (defaults to: `nil`) —

  See #line

    52
    53
    54
    55

    # File 'lib/haml/error.rb', line 52

    def initialize(message = nil, line = nil)
      super(message)
      @line = line
    end

## Instance Attribute Details

### #line ⇒ `Fixnum` (readonly)

The line of the template on which the error occurred.

Returns:

- (`Fixnum`)

    48
    49
    50

    # File 'lib/haml/error.rb', line 48

    def line
      @line
    end

## Class Method Details

### .message(key, *args)

    40
    41
    42
    43

    # File 'lib/haml/error.rb', line 40

    def self.message(key, *args)
      string = MESSAGES[key] or raise "[HAML BUG] No error messages for #{key}"
      (args.empty? ? string : string % args).rstrip
    end