class AI::Provider::TypeValidationError

Overview

Error thrown when type validation fails.

This error provides context about the value that failed validation and the underlying validation error.

Defined in:

ai/provider/errors/type_validation_error.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class AI::Provider::AISDKError

name : String name, to_s(io : IO) : Nil to_s

Constructor methods inherited from class AI::Provider::AISDKError

new(*, name : String, message : String, cause : Exception | Nil = nil) new

Class methods inherited from class AI::Provider::AISDKError

instance?(error) : Bool instance?

Constructor Detail

def self.new(*, value, cause : Exception) #

Creates a new TypeValidationError.

Parameters:

  • value: The value that failed validation (any type)
  • cause: The underlying validation exception

[View source]
def self.wrap(*, value, cause : Exception) : TypeValidationError #

Wraps an error into a TypeValidationError.

If the cause is already a TypeValidationError with the same value, it returns the cause. Otherwise, it creates a new TypeValidationError.

Parameters:

  • value: The value that failed validation
  • cause: The original error or cause of the validation failure

Returns: A TypeValidationError instance


[View source]

Class Method Detail

def self.instance?(error) : Bool #

Checks if the given value is an instance of TypeValidationError.


[View source]

Instance Method Detail

def value : JSON::Any | Nil #

The value that failed type validation. Stored as JSON::Any to handle any type.


[View source]