# Class SmiError

java.lang.Object
com.snmp4j.smi.SmiError

All Implemented Interfaces:
  `SmiErrorInfo`

public final class SmiError extends Object implements SmiErrorInfo
The `SmiError` class represents a syntax or semantic error in a SMI specification file. The error is located at the provided row and column and the defective text is available as well. In addition, error number and message are provided.

Author:
  Frank Fock

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SmiError(String moduleName, int row, int column, int endRow, int endColumn, int position, int errorNumber, String message, String shortMessage, String defectiveText, String[] expectedText)`
  Creates a `SmiError` from error location and description information.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getColumn()`
  Gets the column where the defective text was found in the text file.
  `String`
  `getDefectiveText()`
  The text in the MIB specification that failed to parse.
  `int`
  `getEndColumn()`
  Gets the ending column where the defective text ends in the text file.
  `int`
  `getEndRow()`
  Gets the bottom row of the defective text in the text file.
  `int`
  `getErrorNumber()`
  Gets the error code of the error.
  `String[]`
  `getExpectedText()`
  Returns the expected text alternatives identified by the SMI compiler.
  `String`
  `getMessage()`
  Gets the error message for the error.
  `String`
  `getModuleName()`
  Gets the MIB module name (if available) of the MIB module that contains the error.
  `int`
  `getPosition()`
  Gets the byte position in the input stream where the defective text starts.
  `int`
  `getRow()`
  Gets the row where the defective text was found in the text file.
  `String`
  `getShortMessage()`
  Gets the error message for the error in a short form, without error number and location information.
  `String`
  `toString()`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### SmiError

    public SmiError(String moduleName, int row, int column, int endRow, int endColumn, int position, int errorNumber, String message, String shortMessage, String defectiveText, String[] expectedText)
    Creates a `SmiError` from error location and description information.
    Parameters:
      `moduleName` - the module name of the parse MIB module.
      `row` - the starting row in the file where the error was detected.
      `column` - the starting column in the file where the error was detected.
      `endRow` - the end row in the file where the error was detected.
      `endColumn` - the end column in the file where the error was detected.
      `position` - the character position the file where the error was detected.
      `errorNumber` - the error number.
      `message` - the error message.
      `shortMessage` - a short form of `message`.
      `defectiveText` - the text with the error.
      `expectedText` - the expected text (variants).

- ## Method Details

  - ### getColumn

    public int getColumn()
    Gets the column where the defective text was found in the text file.
    Specified by:
      `getColumn` in interface `SmiErrorInfo`
    Returns:
      the one-based starting column of the error.

  - ### getEndColumn

    public int getEndColumn()
    Gets the ending column where the defective text ends in the text file.
    Specified by:
      `getEndColumn` in interface `SmiErrorInfo`
    Returns:
      the one-based ending column of the error.
    Since:
      1.4

  - ### getErrorNumber

    public int getErrorNumber()
    Gets the error code of the error. See http://www.agentpp.com/mibdesigner3.x/MIBDesigner.pdf for a explanation of the error codes. If you doubt that an error is correctly reported, please first read section 6 "MIB Design" of that PDF document before contacting support.
    Specified by:
      `getErrorNumber` in interface `SmiErrorInfo`
    Returns:
      an error code, numerically identifying the type of error.

  - ### getMessage

    public String getMessage()
    Gets the error message for the error.
    Specified by:
      `getMessage` in interface `SmiErrorInfo`
    Returns:
      a human readable error message describing the error in English.

  - ### getShortMessage

    public String getShortMessage()
    Gets the error message for the error in a short form, without error number and location information.
    Specified by:
      `getShortMessage` in interface `SmiErrorInfo`
    Returns:
      a human readable error message describing the error in English.

  - ### getDefectiveText

    public String getDefectiveText()
    The text in the MIB specification that failed to parse.
    Specified by:
      `getDefectiveText` in interface `SmiErrorInfo`
    Returns:
      a text fragment which is located in the MIB specification at column `getColumn()` and row `getRow()`.

  - ### getRow

    public int getRow()
    Gets the row where the defective text was found in the text file.
    Specified by:
      `getRow` in interface `SmiErrorInfo`
    Returns:
      the one-based starting row of the error.

  - ### getEndRow

    public int getEndRow()
    Gets the bottom row of the defective text in the text file.
    Specified by:
      `getEndRow` in interface `SmiErrorInfo`
    Returns:
      the one-based ending row of the error.
    Since:
      1.4

  - ### getPosition

    public int getPosition()
    Gets the byte position in the input stream where the defective text starts.
    Specified by:
      `getPosition` in interface `SmiErrorInfo`
    Returns:
      the zero-based byte position of the defective text in the SMI specification.
    Since:
      1.4

  - ### getModuleName

    public String getModuleName()
    Gets the MIB module name (if available) of the MIB module that contains the error.
    Specified by:
      `getModuleName` in interface `SmiErrorInfo`
    Returns:
      a MIB module name or `null` if the MIB module name was not determinable.

  - ### getExpectedText

    public String[] getExpectedText()
    Returns the expected text alternatives identified by the SMI compiler.
    Specified by:
      `getExpectedText` in interface `SmiErrorInfo`
    Returns:
      `null` if no text was expected/could be identified as expected. Otherwise, a list of expected text is returned where each element provides one alternative.
    Since:
      1.4

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`