All exceptions in rebootpy inherit from the base FortniteException class. This allows you to catch all library-specific exceptions by catching the base exception.
FortniteException
Base exception for all rebootpy errors.
try:
await client.start()
except rebootpy.FortniteException:
print("A rebootpy error occurred")
All other exceptions inherit from this class, so catching this exception will catch all library-specific errors.
AuthException
Raised when authentication fails due to invalid credentials or other authentication-related issues.
Attributes
The original exception that was raised. Always inherits from FortniteException.
Example
try:
await client.start()
except rebootpy.AuthException as e:
print(f"Authentication failed: {e}")
print(f"Original error: {e.original}")
HTTPException
Raised when an HTTP error is received from Fortnite services. This is one of the most common exceptions you’ll encounter.
Attributes
The HTTP response object from the request.
A formatted error message.
The HTTP status code of the response.
The route or URL that was used for the request.
The raw message or data received from Fortnite services.
The headers that were used in the request.
The error message from Fortnite services.
The error code from Fortnite services.
Arguments passed to the error message.
The numeric error code from Fortnite services.
The service that originated the error.
The product/environment the error was received from.
validation_failures
Optional[List[ValidationFailure]]
List of validation failures if the error was due to validation issues. None otherwise.
Example
try:
user = await client.fetch_profile("invalid_id")
except rebootpy.HTTPException as e:
print(f"HTTP Error: {e.status}")
print(f"Message: {e.message}")
print(f"Code: {e.message_code}")
ValidationFailure
Represents a validation failure returned by Fortnite services. This is not raised directly but is included in HTTPException.validation_failures.
Attributes
The name of the field that failed validation.
The value that was considered invalid.
A message explaining why the field value was invalid.
The raw error message code.
Variables associated with the error message.
Example
try:
await party.set_custom_key("invalid_key", "value")
except rebootpy.HTTPException as e:
if e.validation_failures:
for failure in e.validation_failures:
print(f"Field '{failure.field_name}' is invalid: {failure.message}")
EventError
Raised when something goes wrong with event handling.
try:
# Event-related operation
pass
except rebootpy.EventError as e:
print(f"Event error: {e}")
XMPPError
Raised when an error occurs with the XMPP (chat/presence) service.
try:
await client.xmpp.send_presence()
except rebootpy.XMPPError as e:
print(f"XMPP error: {e}")
PartyError
Raised when a party-related operation fails.
try:
await party.set_privacy(rebootpy.PartyPrivacy.PUBLIC)
except rebootpy.PartyError as e:
print(f"Party error: {e}")
PartyIsFull
Raised when attempting to join a party that is already full.
try:
await party.join()
except rebootpy.PartyIsFull:
print("Cannot join party - it's full")
Forbidden
Raised when attempting an action that your account doesn’t have permission to perform.
try:
await client.fetch_private_data(user_id)
except rebootpy.Forbidden:
print("You don't have permission to perform this action")
NotFound
Raised when a requested resource is not found by Fortnite services.
try:
user = await client.fetch_profile("nonexistent_user")
except rebootpy.NotFound:
print("User not found")
NoMoreItems
Raised when an iterator has no more items to yield.
try:
async for friend in client.fetch_friends():
print(friend.display_name)
except rebootpy.NoMoreItems:
print("No more friends to fetch")
Friendship Exceptions
Multiple exceptions related to friend operations.
DuplicateFriendship
Raised when attempting to add a user who is already a friend.
try:
await client.add_friend(user_id)
except rebootpy.DuplicateFriendship:
print("Already friends with this user")
FriendshipRequestAlreadySent
Raised when attempting to send a friend request to a user who has already received one from you.
try:
await client.add_friend(user_id)
except rebootpy.FriendshipRequestAlreadySent:
print("Friend request already sent to this user")
MaxFriendshipsExceeded
Raised when the client has reached the maximum number of friends.
try:
await client.add_friend(user_id)
except rebootpy.MaxFriendshipsExceeded:
print("You have reached the maximum number of friends")
InviteeMaxFriendshipsExceeded
Raised when the user you’re trying to add has reached their maximum number of friends.
try:
await client.add_friend(user_id)
except rebootpy.InviteeMaxFriendshipsExceeded:
print("This user has reached their maximum number of friends")
InviteeMaxFriendshipRequestsExceeded
Raised when the user you’re trying to add has too many pending friend requests.
try:
await client.add_friend(user_id)
except rebootpy.InviteeMaxFriendshipRequestsExceeded:
print("This user has too many pending friend requests")
FriendOffline
Raised when attempting an action that requires a friend to be online, but they’re offline.
try:
await friend.invite()
except rebootpy.FriendOffline:
print("Friend is offline")
InvalidOffer
Raised when an invalid or outdated item shop offer is used. Only offers currently in the item shop are valid.
try:
await client.purchase_offer(offer_id)
except rebootpy.InvalidOffer:
print("This offer is no longer available")
ChatError
Raised when there’s an issue with the chat service, such as:
- Message is too long
- Attempting to send a message to an empty party
- Other chat-related errors
try:
await party.send("x" * 5000) # Message too long
except rebootpy.ChatError as e:
print(f"Chat error: {e}")
Exception Hierarchy
All exceptions follow this hierarchy:
FortniteException
├── AuthException
├── EventError
├── XMPPError
├── PartyError
├── PartyIsFull
├── Forbidden
├── NotFound
├── NoMoreItems
├── DuplicateFriendship
├── FriendshipRequestAlreadySent
├── MaxFriendshipsExceeded
├── InviteeMaxFriendshipsExceeded
├── InviteeMaxFriendshipRequestsExceeded
├── FriendOffline
├── InvalidOffer
├── ChatError
└── HTTPException
Best Practices
Catch Specific Exceptions
try:
await client.add_friend(user_id)
except rebootpy.DuplicateFriendship:
print("Already friends")
except rebootpy.MaxFriendshipsExceeded:
print("Friend list is full")
except rebootpy.NotFound:
print("User not found")
except rebootpy.HTTPException as e:
print(f"HTTP error: {e.status}")
except rebootpy.FortniteException as e:
print(f"Other error: {e}")
Handle Authentication Errors
try:
await client.start()
except rebootpy.AuthException as e:
print(f"Failed to authenticate: {e}")
if isinstance(e.original, rebootpy.HTTPException):
print(f"Status code: {e.original.status}")
Check Validation Failures
try:
await some_operation()
except rebootpy.HTTPException as e:
if e.validation_failures:
print("Validation errors:")
for failure in e.validation_failures:
print(f" - {failure.field_name}: {failure.message}")
else:
print(f"HTTP error: {e.message}")