Milvex.Error
(milvex v0.10.2)
Copy Markdown
Main error aggregator for Milvex using Splode.
This module provides consistent error handling across all Milvex operations. Errors are classified into four categories:
:invalid- Input validation and constraint violations:connection- Network and connection establishment errors:grpc- gRPC operation and Milvus server response errors:unknown- Unexpected or unclassified errors
Summary
Functions
Raises an error if the result is an error, otherwise returns the result
Types
@type class() :: %{ :__struct__ => class_module(), :__exception__ => true, :errors => [t()], :class => error_class(), :bread_crumbs => [String.t()], :vars => Keyword.t(), :stacktrace => Splode.Stacktrace.t() | nil, :context => map(), optional(atom()) => any() }
@type class_module() ::
Milvex.Errors.Unknown
| Milvex.Errors.Grpc
| Milvex.Errors.Connection
| Milvex.Errors.Invalid
@type error_class() :: :unknown | :grpc | :connection | :invalid
@type t() :: %{ :__struct__ => module(), :__exception__ => true, :class => error_class(), :bread_crumbs => [String.t()], :vars => Keyword.t(), :stacktrace => Splode.Stacktrace.t() | nil, :context => map(), optional(atom()) => any() }
Functions
Raises an error if the result is an error, otherwise returns the result
Alternatively, you can use the defsplode macro, which does this automatically.
Options
:error_opts- Options to pass toto_error/2when converting the returned error:unknown_error_opts- Options to pass to the unknown error if the function returns only:error. not necessary if your function always returns{:error, error}.
Examples
def function(arg) do
case do_something(arg) do
:success -> :ok
{:success, result} -> {:ok, result}
{:error, error} -> {:error, error}
endend
def function!(arg) do
YourErrors.unwrap!(function(arg))end