promptguard.exceptions

All exceptions inherit from PromptGuardError so you can catch the entire hierarchy with a single except clause.

from promptguard.exceptions import PromptGuardError

try:
    result = guard.analyze(prompt)
except PromptGuardError as e:
    print(f"PromptGuard error: {e}")
class promptguard.PromptGuardError[source]

Bases: Exception

Base exception for PromptGuard errors.

class promptguard.ModelLoadError[source]

Bases: PromptGuardError

Raised when model fails to load.

class promptguard.ValidationError[source]

Bases: PromptGuardError

Raised when input validation fails.

class promptguard.ConfigurationError[source]

Bases: PromptGuardError

Raised when configuration is invalid.

class promptguard.InferenceError[source]

Bases: PromptGuardError

Raised when inference fails.