Skip to content

AiSdkError

Namespace: Vercel.AI.Util

public class AiSdkError : Exception, ISerializable, IErrorMarkers

Base error for upstream AI SDK error types. Marker checks work without a shared assembly.

Inheritance: object → Exception

Implements: ISerializable, IErrorMarkers

Derived: NoSuchProviderReferenceError, SerializationError, ApiCallError, DecisionRefusalError, DecisionUnsupportedQuestionTypeError, DownloadError, InvalidArgumentError, InvalidToolInputError, NoSuchModelError, NoSuchToolError, RetryError, StreamProviderError, ToolCallRepairError

View source

public AiSdkError(string? name, string message, Exception? cause = null)

Creates an error with the upstream <code class=“paramref”>name</code> and <code class=“paramref”>message</code>.

Parameters

Name Type Description
name string
message string
cause Exception

View source

public const string Marker = "vercel.ai.error"

Marker present on every AI SDK error.

Value: string

View source

public Exception? Cause { get; }

Underlying cause, when one was supplied.

Value: Exception

View source

public string ErrorName { get; }

Upstream error name, such as AI_APICallError.

Value: string

View source

public static bool HasMarker(object? error, string? marker)

Returns whether <code class=“paramref”>error</code> has <code class=“paramref”>marker</code> set to true.

Parameters

Name Type Description
error object
marker string

Returns: bool

View source

public bool HasMarker(string marker)

Returns whether <code class=“paramref”>marker</code> is set to true.

Parameters

Name Type Description
marker string

Returns: bool

View source

public static bool IsInstance(object? error)

Returns whether <code class=“paramref”>error</code> carries the base AI SDK marker.

Parameters

Name Type Description
error object

Returns: bool

View source

protected void SetMarker(string marker, bool value)

Records a marker used by String).

Parameters

Name Type Description
marker string
value bool

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product