Exception
This page lists non-exported (internal) symbols of CTBase.
Access these symbols with:
import CTBase
CTBase.<NAME>AmbiguousDescription
CTBase.AmbiguousDescription — Type
struct AmbiguousDescription <: CTBase.CTExceptionException 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 / incorrectThis error is useful to signal when a user provides a description that cannot be matched to any known valid descriptions.
CTException
CTBase.CTException — Type
abstract type CTException <: ExceptionAbstract 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 inputExtensionError
CTBase.ExtensionError — Type
struct ExtensionError <: CTBase.CTExceptionException 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 MyExtensionIncorrectArgument
CTBase.IncorrectArgument — Type
struct IncorrectArgument <: CTBase.CTExceptionException 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 tupleNotImplemented
CTBase.NotImplemented — Type
struct NotImplemented <: CTBase.CTExceptionException 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 implementedParsingError
CTBase.ParsingError — Type
struct ParsingError <: CTBase.CTExceptionException 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 tokenUnauthorizedCall
CTBase.UnauthorizedCall — Type
struct UnauthorizedCall <: CTBase.CTExceptionException 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 permissionBase.showerror
Base.showerror — Function
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 exceptionshowerror(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 / incorrectshowerror(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