Exception

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

Access these symbols with:

import CTBase
CTBase.<NAME>

AmbiguousDescription

CTBase.AmbiguousDescriptionType
struct AmbiguousDescription <: CTBase.CTException

Exception thrown when a description is ambiguous or does not match any known descriptions.

Fields

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

Example

julia> using CTBase

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

This error is useful to signal when a user provides a description that cannot be matched to any known valid descriptions.

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.

Fields

  • weakdeps::Tuple{Vararg{Symbol}}: The tuple of symbols representing the missing dependencies.

Constructor

Throws UnauthorizedCall if no weak dependencies are provided.

Example

julia> using CTBase

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

IncorrectArgument

CTBase.IncorrectArgumentType
struct IncorrectArgument <: CTBase.CTException

Exception thrown when an argument passed to a function or constructor is inconsistent, invalid, or does not satisfy preconditions.

Fields

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

Example

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

NotImplemented

CTBase.NotImplementedType
struct NotImplemented <: CTBase.CTException

Exception thrown when a method or function has not been implemented yet.

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

ParsingError

CTBase.ParsingErrorType
struct ParsingError <: CTBase.CTException

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

Fields

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

Example

julia> using CTBase

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

UnauthorizedCall

CTBase.UnauthorizedCallType
struct UnauthorizedCall <: CTBase.CTException

Exception thrown when a function call is not authorized in the current context or with the given arguments.

Fields

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

Example

julia> using CTBase

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

Base.showerror

Base.showerrorFunction
showerror(io, e)

Show a descriptive representation of an exception object e. This method is used to display the exception after a call to throw.

Examples

julia> struct MyException <: Exception
           msg::String
       end

julia> function Base.showerror(io::IO, err::MyException)
           print(io, "MyException: ")
           print(io, err.msg)
       end

julia> err = MyException("test exception")
MyException("test exception")

julia> sprint(showerror, err)
"MyException: test exception"

julia> throw(MyException("test exception"))
ERROR: MyException: test exception
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
showerror(io::IO, e::CTBase.IncorrectArgument)

Customizes the printed message of the exception.

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

Customizes the printed message of the exception.

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

Customizes the printed message of the exception.

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

Customizes the printed message of the exception.

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