Exception

Index

Warning

In the examples in the documentation below, the methods are not prefixed by the module name even if they are private.

julia> using CTBase
julia> x = 1
julia> private_fun(x) # throw an error

must be replaced by

julia> using CTBase
julia> x = 1
julia> CTBase.private_fun(x)

However, if the method is reexported by another package, then, there is no need of prefixing.

julia> module OptimalControl
           import CTBase: private_fun
           export private_fun
       end
julia> using OptimalControl
julia> x = 1
julia> private_fun(x)

Documentation

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> 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.

source
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> try
           throw(IncorrectArgument("invalid input"))
       catch e::CTException
           println("Caught a domain-specific exception: ", e)
       end
Caught a domain-specific exception: IncorrectArgument: invalid input
source
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> throw(ExtensionError(:MyExtension))
ERROR: ExtensionError. Please make: julia> using MyExtension
source
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> throw(IncorrectArgument("the argument must be a non-empty tuple"))
ERROR: IncorrectArgument: the argument must be a non-empty tuple
source
CTBase.IncorrectMethodType
struct IncorrectMethod <: CTBase.CTException

Exception thrown when a specified method name or function symbol does not exist.

Fields

  • var::Symbol: The method or function symbol that was expected but not found.

Example

julia> throw(IncorrectMethod(:nonexistent_func))
ERROR: IncorrectMethod: nonexistent_func is not an existing method
source
CTBase.IncorrectOutputType
struct IncorrectOutput <: CTBase.CTException

Exception thrown when the output produced by a function is incorrect or inconsistent with expected results.

Fields

  • var::String: A descriptive message explaining the incorrect output.

Example

julia> throw(IncorrectOutput("the function returned NaN"))
ERROR: IncorrectOutput: the function returned NaN
source
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> throw(NotImplemented("feature X is not implemented"))
ERROR: NotImplemented: feature X is not implemented
source
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> throw(ParsingError("unexpected token"))
ERROR: ParsingError: unexpected token
source
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> throw(UnauthorizedCall("user does not have permission"))
ERROR: UnauthorizedCall: user does not have permission
source
Base.showerrorMethod
showerror(io::IO, e::CTBase.AmbiguousDescription)

Customizes the printed message of the exception.

Example

julia> throw(AmbiguousDescription((:x, :y)))
ERROR: AmbiguousDescription: the description (:x, :y) is ambiguous / incorrect
source
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> e = ExtensionError(:MyExtension, :AnotherDep)
julia> showerror(stdout, e)
ERROR: ExtensionError. Please make: julia> using MyExtension, AnotherDep
source
Base.showerrorMethod
showerror(io::IO, e::CTBase.IncorrectArgument)

Customizes the printed message of the exception.

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

Customizes the printed message of the exception.

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

Customizes the printed message of the exception.

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

Customizes the printed message of the exception.

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

Customizes the printed message of the exception.

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

Customizes the printed message of the exception.

source