NAME

Zuzu::Error - base structured error object for Zuzu

DESCRIPTION

Provides shared message/location attributes and string formatting for all Zuzu error classes.

Most callers should construct a subclass via new_compile or new_runtime, which return Zuzu::Error::Compile and Zuzu::Error::Runtime objects respectively.

INHERITANCE

Inherits from Moo::Object.

ROLES

None.

ATTRIBUTES

message

Type: Str.

Human-readable error message.

file

Type: Maybe[Str].

Source filename used for diagnostics.

line

Type: Int.

1-based source line number used for diagnostics.

code

Type: Str.

Machine-readable stable error code.

METHODS

new_compile

Creates and returns a Zuzu::Error::Compile object.

new_runtime

Creates and returns a Zuzu::Error::Runtime object.

kind

Returns the error category label.

The base implementation returns Error. Subclasses override this.

as_struct

Returns machine-readable metadata as a hash reference.

as_string

Formats the error as a single diagnostic string.

SEE ALSO

Zuzu::Error::Compile, Zuzu::Error::Runtime.

COPYRIGHT AND LICENCE

Zuzu::Error is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.