julia
Julia Exceptions
Exception types thrown by the Julia runtime and standard library, covering type errors, bounds violations, I/O failures, and concurrency errors.
17 codes
· All codes 17 codes
- ArgumentError Invalid Argument A function received an argument that is of the correct type but has an invalid value (e.g. a negative length, an empty collection where one element is required). The error message describes the specific constraint that was violated.
- BoundsError Index Out of Bounds An attempt was made to access an array or other indexable object at an index that is outside its valid range. Julia arrays are 1-indexed by default. Check the array size with length() or size() and verify the index.
- DivideError Integer Division by Zero An integer division or remainder operation was attempted with a divisor of zero. Unlike floating-point division, integer division does not produce Inf; it throws this error. Check the divisor before dividing.
- DomainError Argument Outside Valid Domain A mathematical or algorithmic function received an argument outside its defined domain — for example, sqrt(-1) or log(0) with real-valued functions. Use the complex variants (sqrt(complex(-1))) or check argument bounds before calling.
- ErrorException Generic Error The base error type thrown by error() with a message string. It is the catch-all exception in Julia when no more specific type applies. The message field describes what went wrong.
- InexactError Inexact Conversion A value could not be converted to the target type without loss of precision. For example, converting 1.5 to Int64 raises this error. Use round(), floor(), or ceil() to explicitly choose a rounding mode before converting.
- InterruptException Execution Interrupted Execution was interrupted by a signal, typically Ctrl+C from the user. In long-running computations, consider periodically checking for this exception to allow clean cancellation.
- KeyError Key Not Found A dictionary lookup or similar keyed access failed because the key does not exist. Use get(dict, key, default) or haskey(dict, key) to avoid the error when the key's presence is uncertain.
- LoadError Error While Loading File An error occurred while loading or including a Julia source file. The LoadError wraps the original exception; inspect the 'error' field or the full stack trace to find the root cause.
- MethodError No Matching Method No method exists for the function with the given argument types. Julia uses multiple dispatch, so this means no method was defined for that specific combination of argument types. Check the type of each argument and look for applicable method signatures.
- OutOfMemoryError Out of Memory The Julia runtime could not allocate the requested amount of memory. This can be caused by allocating very large arrays, memory leaks, or insufficient system RAM. Profile with @allocated or reduce the size of intermediate arrays.
- OverflowError Arithmetic Overflow An arithmetic operation produced a result that is outside the representable range of the integer type. Use a wider integer type (Int128, BigInt) or check for overflow before the operation with Base.checked_add and friends.
- StackOverflowError Stack Overflow The call stack grew too deep, typically due to unbounded or missing-base-case recursion. Add a base case, increase the stack size with JULIA_THREAD_STACK_SIZE, or convert the recursion to an iterative approach.
- SystemError OS System Call Error An operating system call failed. The error message includes the system error number and description (equivalent to errno). Common causes include missing files, permission denials, or resource exhaustion.
- TaskFailedException Async Task Failed A Task (coroutine) finished with an unhandled exception. When you fetch() or wait() on a failed task, Julia re-throws the task's exception wrapped in a TaskFailedException. Inspect the 'task' field's exception for the root cause.
- TypeError Type Assertion Failed A type assertion (::) or type check failed because the value's type does not match the expected type. This can also occur when a function expects a specific concrete type in a context that does not allow implicit conversion.
- UndefVarError Undefined Variable A variable was referenced before it was assigned, or it is not in scope at the point of use. Check for typos in the variable name, ensure it is defined before use, and be aware of Julia's scoping rules for closures and loops.