7 Texinfo::Report


7.1 Texinfo::Report NAME

Texinfo::Report - Error storing for Texinfo modules


7.2 Texinfo::Report SYNOPSIS

  use Texinfo::Report;

  my $registrar = Texinfo::Report::new();

  if ($warning_happened) {
    $registrar->line_warn($converter, sprintf(__("\@%s is wrongly used"),
                       $current->{'cmdname'}), $current->{'source_info'});
  }

  my ($errors, $errors_count) = $registrar->errors();
  foreach my $error_message (@$errors) {
    warn $error_message->{'error_line'};
  }

  $registrar->clear();

7.3 Texinfo::Report NOTES

The Texinfo Perl module main purpose is to be used in texi2any to convert Texinfo to other formats. There is no promise of API stability.


7.4 Texinfo::Report DESCRIPTION

The Texinfo::Report module helps with error handling. Errors and warnings can be setup, stored and retrieved later on. This module is used by the Texinfo modules Texinfo::Parser and Texinfo::Convert::Converter.


7.5 Texinfo::Report METHODS

No method is exported in the default case.

The new method initializes a Texinfo::Report object. The errors collected are available through the errors method, the other methods allow registering errors and warnings.

my $registrar = Texinfo::Report::new()

Return an initialized Texinfo::Report object.

($error_warnings_list, $error_count) = errors($registrar)

This function returns as $error_count the count of errors since calling new. The $error_warnings_list is an array of hash references one for each error, warning or error line continuation. Each of these has the following keys:

continuation

If set, the line is a continuation line of a message.

error_line

The text of the error formatted with the macro name, as needed.

file_name

The file name where the error or warning occurs.

line_nr

The line number of the error or warning.

macro

The user macro name that is expanded at the location of the error or warning.

text

The text of the error.

type

May be warning, or error.

$registrar->clear ()

Clear the previously registered messages.

$registrar->add_formatted_message ($msg)

Register the $msg hash reference corresponding to an error, warning or error line continuation. The $msg hash reference should correspond to the structure returned by errors.

$registrar->line_warn($text, $error_location_info, $continuation, $debug, $silent)
$registrar->line_error($text, $error_location_info, $continuation, $debug, $silent)

Register a warning or an error. The $text is the text of the error or warning. The mandatory $error_location_info holds the information on the error or warning location. The $error_location_info reference on hash may be obtained from Texinfo elements source_info keys. It may also be setup to point to a file name, using the file_name key and to a line number, using the line_nr key. The file_name key value should be a binary string.

The $continuation optional arguments, if true, conveys that the line is a continuation line of a message.

The $debug optional integer arguments sets the debug level.

The $silent optional arguments, if true, suppresses the output of a message that is output immediatly if debugging is set.

The source_info key of Texinfo tree elements is described in more details in Texinfo::Parser source_info.

$registrar->document_warn($text, $program_name, $continuation)
$registrar->document_error($text, $program_name, $continuation)

Register a document-wide error or warning. $text is the error or warning message. The $program_name is prepended to the message, if defined. The $continuation optional arguments, if true, conveys that the line is a continuation line of a message.


7.6 Texinfo::Report AUTHOR

Patrice Dumas, <pertusus@free.fr>