Private API

This page lists non-exported (internal) symbols of CTBase.


From CTBase

AmbiguousDescription

CTBase.AmbiguousDescriptionType
struct AmbiguousDescription <: CTBase.CTException

Exception thrown when a description (a tuple of Symbols) cannot be matched to any known valid descriptions.

This exception is raised by CTBase.complete() when the user provides an incomplete or inconsistent description that doesn't match any of the available descriptions in the catalogue. Use this exception when the high-level choice of description itself is wrong or ambiguous and there is no sensible default.

Fields

  • var::Tuple{Vararg{Symbol}}: The ambiguous or incorrect description tuple that caused the error.

Example

julia> using CTBase

julia> D = ((:a, :b), (:a, :b, :c), (:b, :c))
julia> CTBase.complete(:f; descriptions=D)
ERROR: AmbiguousDescription: the description (:f,) is ambiguous / incorrect

In this example, the symbol :f does not appear in any of the known descriptions, so complete() cannot determine which description to return.

See Also

CTException

CTBase.CTExceptionType
abstract type CTException <: Exception

Abstract supertype for all custom exceptions in this module.

Use this as the common ancestor for all domain-specific errors to allow catching all exceptions of this family via catch e::CTException.

No fields.

Example

julia> using CTBase

julia> try
           throw(CTBase.IncorrectArgument("invalid input"))
       catch e::CTBase.CTException
           println("Caught a domain-specific exception: ", e)
       end
Caught a domain-specific exception: IncorrectArgument: invalid input

ExtensionError

CTBase.ExtensionErrorType
struct ExtensionError <: CTBase.CTException

Exception thrown when an extension or optional dependency is not loaded but a function requiring it is called.

This exception is used to signal that a feature requires one or more optional dependencies (weak dependencies) to be loaded. When a user tries to use a feature without loading the required extensions, this exception provides a helpful message indicating exactly which packages need to be loaded.

It is also used internally by ExtensionError() when called without any weak dependencies, in which case it throws UnauthorizedCall instead.

Fields

  • weakdeps::Tuple{Vararg{Symbol}}: The tuple of symbols representing the missing dependencies.
  • var::String: An optional message to display after the "Please make: ..." instruction.

Constructor

ExtensionError(weakdeps::Symbol...; message::String="")

Throws UnauthorizedCall if no weak dependencies are provided:

CTBase.ExtensionError()  # Throws UnauthorizedCall

Examples

julia> using CTBase

julia> throw(CTBase.ExtensionError(:MyExtension))
ERROR: ExtensionError. Please make: julia> using MyExtension

With multiple dependencies and a custom message:

julia> throw(CTBase.ExtensionError(:MyExtension, :AnotherDep; message="to use this feature"))
ERROR: ExtensionError. Please make: julia> using MyExtension, AnotherDep to use this feature

See Also

IncorrectArgument

CTBase.IncorrectArgumentType
struct IncorrectArgument <: CTBase.CTException

Exception thrown when an individual argument is invalid or violates a precondition.

This exception is raised when one input value is outside the allowed domain, such as:

  • Wrong range or bounds (e.g., negative when positive is required)
  • Duplicate values when uniqueness is required
  • Empty collections when non-empty is required
  • Type mismatches or invalid combinations

Use this exception to signal that the problem is with the input data itself, not with the state of the system or the calling context. This is distinct from UnauthorizedCall, which indicates a state-related issue.

Fields

  • var::String: A descriptive message explaining the nature of the incorrect argument.

Examples

julia> using CTBase

julia> throw(CTBase.IncorrectArgument("the argument must be a non-empty tuple"))
ERROR: IncorrectArgument: the argument must be a non-empty tuple

Adding a duplicate description to a catalogue:

julia> algorithms = CTBase.add((), (:a, :b))
julia> CTBase.add(algorithms, (:a, :b))
ERROR: IncorrectArgument: the description (:a, :b) is already in ((:a, :b),)

Invalid indices for Unicode helpers:

julia> CTBase.ctindice(-1)
ERROR: IncorrectArgument: the subscript must be between 0 and 9

See Also

NotImplemented

CTBase.NotImplementedType
struct NotImplemented <: CTBase.CTException

Exception thrown to mark interface points that must be implemented by concrete subtypes.

This exception is used to define abstract interfaces where a default method on an abstract type throws NotImplemented, and each concrete implementation must override it. This makes it easy to detect missing implementations during testing and development.

Use NotImplemented when defining interfaces and you want an explicit, typed error rather than a generic error("TODO").

Fields

  • var::String: A message indicating what functionality is not yet implemented.

Example

julia> using CTBase

julia> throw(CTBase.NotImplemented("feature X is not implemented"))
ERROR: NotImplemented: feature X is not implemented

A typical pattern for defining an interface:

abstract type MyAbstractAlgorithm end

function run!(algo::MyAbstractAlgorithm, state)
    throw(CTBase.NotImplemented("run! is not implemented for $(typeof(algo))"))
end

Concrete algorithms then provide their own run! method instead of raising this exception.

See Also

ParsingError

CTBase.ParsingErrorType
struct ParsingError <: CTBase.CTException

Exception thrown during parsing when a syntax error or invalid structure is detected.

This exception is intended for errors detected during parsing of input structures or domain-specific languages (DSLs). Use this when processing user input that follows a specific grammar or format, and the input violates the expected syntax.

Fields

  • var::String: A message describing the parsing error.

Example

julia> using CTBase

julia> throw(CTBase.ParsingError("unexpected token 'end'"))
ERROR: ParsingError: unexpected token 'end'

See Also

UnauthorizedCall

CTBase.UnauthorizedCallType
struct UnauthorizedCall <: CTBase.CTException

Exception thrown when a function call is not allowed in the current state of the object or system.

This exception signals that the arguments may be valid, but the call is forbidden because of when or how it is made. This is distinct from IncorrectArgument, which indicates a problem with the input values themselves.

Common use cases:

  • A method that is meant to be called only once
  • State already closed or finalized
  • Missing permissions or access rights
  • Illegal order of operations
  • Wrong phase of a computation

Fields

  • var::String: A message explaining why the call is unauthorized.

Examples

julia> using CTBase

julia> throw(CTBase.UnauthorizedCall("user does not have permission"))
ERROR: UnauthorizedCall: user does not have permission

A typical pattern for state-dependent operations:

function finalize!(s::SomeState)
    if s.is_finalized
        throw(CTBase.UnauthorizedCall("finalize! was already called for this state"))
    end
    # ... perform finalisation and mark state as finalised ...
end

See Also

Base.showerror

Base.showerrorMethod
showerror(io::IO, e::CTBase.AmbiguousDescription)

Customizes the printed message of the exception.

Example

julia> using CTBase

julia> throw(CTBase.AmbiguousDescription((:x, :y)))
ERROR: AmbiguousDescription: the description (:x, :y) is ambiguous / incorrect

Base.showerror

Base.showerrorMethod
showerror(io::IO, e::CTBase.ParsingError)

Customizes the printed message of the exception.

Base.showerror

Base.showerrorMethod
showerror(io::IO, e::CTBase.IncorrectArgument)

Customizes the printed message of the exception.

Base.showerror

Base.showerrorMethod
showerror(io::IO, e::CTBase.UnauthorizedCall)

Customizes the printed message of the exception.

Base.showerror

Base.showerrorMethod
showerror(io::IO, e::CTBase.NotImplemented)

Customizes the printed message of the exception.

Base.showerror

Base.showerrorMethod
showerror(io::IO, e::CTBase.ExtensionError)

Customizes the printed message of the exception, prompting the user to load the required extensions.

Example

julia> using CTBase

julia> e = CTBase.ExtensionError(:MyExtension, :AnotherDep)
julia> showerror(stdout, e)
ERROR: ExtensionError. Please make: julia> using MyExtension, AnotherDep