Exceptions

Module

Types

PDFHighlights.Internal.Exceptions.NotFiveColumnsType
NotFiveColumns <: Exception

Exception thrown when the row does not represent elements for 5 columns.

Fields

  • file::String: absolute or relative path to a file that is associated with the exception
  • line::Int: line number of the specified file to which this exception is associated

See also: @exception_with_line

Macros

PDFHighlights.Internal.Exceptions.@docstringMacro
@docstring(macro_name::Symbol) -> Expr

Redefine the docstring variable in the innermost macro.

Arguments

  • macro_name::Symbol: name of the macro that generated the exception

Returns

  • Expr: docstring redefinition

Example

using PDFHighlights
using SyntaxTree

macro_name = QuoteNode(:name)

@macroexpand(PDFHighlights.Internal.Exceptions.@docstring(name)) |> linefilter! ==
quote
    macro_name = $(macro_name)
    docstring = Meta.quot(
        """
            $(exception_name) <: Exception

        $(docstring)

        $(fields)

        See also: [`@$(macro_name)`](@ref)
        """
    )
end |> linefilter!
source
PDFHighlights.Internal.Exceptions.@exception_with_fileMacro
@exception_with_file(
    exception_name::Symbol,
    docstring::Union{Expr, String},
    error_message_bits::Tuple{Vararg{Union{Expr, String}}},
) -> Expr

Create an exception with one field: a path to the file.

Arguments

  • exception_name::Symbol: name of the exception
  • docstring::Union{Expr, String}: documentation string
  • error_message_bits::Tuple{Vararg{Union{Expr, String}}}: strings and expressions which will be interpolated in the showerror output

Returns

  • Expr: an exception definition (struct + showerror overload)
source
PDFHighlights.Internal.Exceptions.@exception_with_lineMacro
@exception_with_line(
    exception_name::Symbol,
    docstring::Union{Expr, String},
    error_message_bits::Tuple{Vararg{Union{Expr, String}}},
) -> Expr

Create an exception with two fields: a path to the file and a line number.

Arguments

  • exception_name::Symbol: name of the exception
  • docstring::Union{Expr, String}: documentation string
  • error_message_bits::Tuple{Vararg{Union{Expr, String}}}: strings and expressions which will be interpolated in the showerror output

Returns

  • Expr: an exception definition (struct + showerror overload)
source
PDFHighlights.Internal.Exceptions.@exception_without_fieldsMacro
@exception_without_fields(
    exception_name::Symbol,
    docstring::Union{Expr, String},
    error_message_bits::Tuple{Vararg{Union{Expr, String}}},
) -> Expr

Create an exception with no fields.

Arguments

  • exception_name::Symbol: name of the exception
  • docstring::Union{Expr, String}: documentation string
  • error_message_bits::Tuple{Vararg{Union{Expr, String}}}: strings and expressions which will be interpolated in the showerror output

Returns

  • Expr: an exception definition (struct + showerror overload)
source
PDFHighlights.Internal.Exceptions.@fieldsMacro
@fields(strings::String...) -> Expr

Define the fields variable in the innermost macro. This variable is a string that describes type fields.

Arguments

  • strings::Tuple{Vararg{String}}: strings to store in the fields variable

Returns

  • Expr: fields definition

Example

using PDFHighlights
using SyntaxTree

strings = ("`Cloverfield`: there's no place like home",)

@macroexpand(
    PDFHighlights.Internal.Exceptions.@fields(
        "`Cloverfield`: there's no place like home"
    )
) |> linefilter! == quote
    strings = $(strings) |> collect
    strings = join(["- " * string for string in strings], '\n')
    fields = """
    # Fields\n
    $(strings)
    """
end |> linefilter!
source