Errors

The Files.com Python SDK will return errors by raising exceptions. There are many exception classes defined in the Files SDK that correspond to specific errors.

The raised exceptions come from two categories:

  1. SDK Exceptions - errors that originate within the SDK
  2. API Exceptions - errors that occur due to the response from the Files.com API. These errors are grouped into common error types.

There are several types of exceptions within each category. Exception classes indicate different types of errors and are named in a fashion that describe the general premise of the originating error. More details can be found in the err object message.

Use standard Python exception handling to detect and deal with errors. It is generally recommended to handle specific errors first, then handle the general files_sdk.error.Error exception as a catch-all.

Example Error Handling

import files_sdk

try:
  session = files_sdk.session.create({ "username": "USERNAME", "password": "BADPASSWORD" })
except files_sdk.error.NotAuthenticatedError as err:
  print(f"Authentication Error Occurred ({type(err).__name__}):", err)
except files_sdk.error.Error as err:
  print(f"Unknown Error Occurred ({type(err).__name__}):", err)

SDK Errors

SDK errors are general errors that occur within the SDK code. Each exception class inherits from a standard Error base class.

Example SDK Exception Class Inheritance Structure

files_sdk.error.APIConnectionError -> files_sdk.error.Error -> Exception

SDK Exception Classes

Error Class NameDescription
APIConnectionErrorThe Files.com API cannot be reached, or its response is malformed or unreliable
DeadlineExceededErrorAn APIConnectionError: the operation ran out of the time its request_timeout or deadline allowed
OperationCancelledErrorThe operation's cancel_token was cancelled
ClientClosedErrorAn OperationCancelledError: the operation's client was closed
AuthenticationErrorNot enough authentication information has been provided
InvalidRequestErrorThe SDK refused to go on, such as for a file that changed while it transferred, a checkpoint it cannot use, or a remote file whose upload already failed
InvalidParameterErrorAn InvalidRequestError: a passed in parameter or option is invalid
MissingParameterErrorAn InvalidRequestError: a method parameter is missing
TransferPausedErrorA transfer stopped because its pause_token was paused; its checkpoint resumes it
FileMigrationErrorA copy or move that was waited for failed or was cancelled; its migration, when Files.com made one, says why
NotImplementedErrorThe called method has not be implemented by the SDK

APIConnectionError, DeadlineExceededError and OperationCancelledError have phase, the step that failed, and remote_outcome_unknown, which is True when the request may already have reached Files.com.

Local file problems raise Python's own OSError subclasses, such as files_sdk.localfs.AccessNotKept when a download cannot keep a replaced file's owner, group or access control list. A remote file opened with files_sdk.open() raises io.UnsupportedOperation for what it cannot do, such as seek(), as Python's own files do.

API Errors

API errors are errors returned by the Files.com API. Each exception class inherits from an error group base class. The error group base class indicates a particular type of error.

Example API Exception Class Inheritance Structure

files_sdk.error.FolderAdminPermissionRequiredError -> files_sdk.error.NotAuthorizedError -> files_sdk.error.APIError -> files_sdk.error.Error -> Exception

API Exception Classes

Error Class NameError Group
AgentUpgradeRequiredErrorBadRequestError
AttachmentTooLargeErrorBadRequestError
CannotDownloadDirectoryErrorBadRequestError
CantMoveWithMultipleLocationsErrorBadRequestError
DatetimeParseErrorBadRequestError
DestinationSameErrorBadRequestError
DestinationSiteMismatchErrorBadRequestError
DoesNotSupportSortingErrorBadRequestError
FolderMustNotBeAFileErrorBadRequestError
FoldersNotAllowedErrorBadRequestError
InternalGeneralErrorErrorBadRequestError
InvalidBodyErrorBadRequestError
InvalidCursorErrorBadRequestError
InvalidCursorTypeForSortErrorBadRequestError
InvalidEtagsErrorBadRequestError
InvalidFilterAliasCombinationErrorBadRequestError
InvalidFilterFieldErrorBadRequestError
InvalidFilterParamErrorBadRequestError
InvalidFilterParamFormatErrorBadRequestError
InvalidFilterParamValueErrorBadRequestError
InvalidInputEncodingErrorBadRequestError
InvalidInterfaceErrorBadRequestError
InvalidOauthProviderErrorBadRequestError
InvalidPathErrorBadRequestError
InvalidReturnToUrlErrorBadRequestError
InvalidSearchQueryErrorBadRequestError
InvalidSortFieldErrorBadRequestError
InvalidSortFilterCombinationErrorBadRequestError
InvalidUploadOffsetErrorBadRequestError
InvalidUploadPartGapErrorBadRequestError
InvalidUploadPartSizeErrorBadRequestError
InvalidWorkspaceIdHeaderErrorBadRequestError
MethodNotAllowedErrorBadRequestError
MultipleSortParamsNotAllowedErrorBadRequestError
NoValidInputParamsErrorBadRequestError
OffsetUploadNotAllowedWithMalwareScanningErrorBadRequestError
PartNumberTooLargeErrorBadRequestError
PathCannotHaveTrailingWhitespaceErrorBadRequestError
ReauthenticationNeededFieldsErrorBadRequestError
RequestBodyTooLargeErrorBadRequestError
RequestParamsContainInvalidCharacterErrorBadRequestError
RequestParamsInvalidErrorBadRequestError
RequestParamsRequiredErrorBadRequestError
SearchAllOnChildPathErrorBadRequestError
UnrecognizedSortIndexErrorBadRequestError
UnsupportedCurrencyErrorBadRequestError
UnsupportedHttpResponseFormatErrorBadRequestError
UnsupportedMediaTypeErrorBadRequestError
UserIdInvalidErrorBadRequestError
UserIdOnUserEndpointErrorBadRequestError
UserRequiredErrorBadRequestError
AdditionalAuthenticationRequiredErrorNotAuthenticatedError
ApiKeySessionsNotSupportedErrorNotAuthenticatedError
AuthenticationRequiredErrorNotAuthenticatedError
BundleRegistrationCodeFailedErrorNotAuthenticatedError
InboxRegistrationCodeFailedErrorNotAuthenticatedError
InvalidCredentialsErrorNotAuthenticatedError
InvalidOauthErrorNotAuthenticatedError
InvalidOrExpiredCodeErrorNotAuthenticatedError
InvalidSessionErrorNotAuthenticatedError
InvalidUsernameOrPasswordErrorNotAuthenticatedError
LockedOutErrorNotAuthenticatedError
LockoutRegionMismatchErrorNotAuthenticatedError
OneTimePasswordIncorrectErrorNotAuthenticatedError
TwoFactorAuthenticationErrorErrorNotAuthenticatedError
TwoFactorAuthenticationSetupExpiredErrorNotAuthenticatedError
ApiKeyIsDisabledErrorNotAuthorizedError
ApiKeyIsPathRestrictedErrorNotAuthorizedError
ApiKeyOnlyForDesktopAppErrorNotAuthorizedError
ApiKeyOnlyForFileOperationsErrorNotAuthorizedError
ApiKeyOnlyForMobileAppErrorNotAuthorizedError
ApiKeyOnlyForOfficeIntegrationErrorNotAuthorizedError
BillingInformationHiddenErrorNotAuthorizedError
BillingPermissionRequiredErrorNotAuthorizedError
BundleMaximumUsesReachedErrorNotAuthorizedError
BundlePermissionRequiredErrorNotAuthorizedError
CannotAdministerHigherLevelUserErrorNotAuthorizedError
CannotLoginWhileUsingKeyErrorNotAuthorizedError
CantActForOtherUserErrorNotAuthorizedError
ContactAdminForPasswordChangeHelpErrorNotAuthorizedError
FilesAgentFailedAuthorizationErrorNotAuthorizedError
FolderAdminOrBillingPermissionRequiredErrorNotAuthorizedError
FolderAdminPermissionRequiredErrorNotAuthorizedError
FullPermissionRequiredErrorNotAuthorizedError
HistoryPermissionRequiredErrorNotAuthorizedError
InAppAiAssistantUnavailableErrorNotAuthorizedError
InsufficientPermissionForParamsErrorNotAuthorizedError
InsufficientPermissionForSiteErrorNotAuthorizedError
MoverAccessDeniedErrorNotAuthorizedError
MoverPackageRequiredErrorNotAuthorizedError
MustAuthenticateWithApiKeyErrorNotAuthorizedError
NeedAdminPermissionForInboxErrorNotAuthorizedError
NonAdminsMustQueryByFolderOrPathErrorNotAuthorizedError
NotAllowedToCreateBundleErrorNotAuthorizedError
NotEnqueuableSyncErrorNotAuthorizedError
PasswordChangeNotRequiredErrorNotAuthorizedError
PasswordChangeRequiredErrorNotAuthorizedError
PaymentMethodErrorErrorNotAuthorizedError
PreviewOnlyPermissionCannotDownloadErrorNotAuthorizedError
ReadOnlySessionErrorNotAuthorizedError
ReadPermissionRequiredErrorNotAuthorizedError
ReauthenticationFailedErrorNotAuthorizedError
ReauthenticationFailedFinalErrorNotAuthorizedError
ReauthenticationNeededActionErrorNotAuthorizedError
RecaptchaFailedErrorNotAuthorizedError
RemoteDesktopDebugLoggingDisabledErrorNotAuthorizedError
RootFolderBehaviorSiteAdminRequiredErrorNotAuthorizedError
RootFolderBehaviorSkipSiteAdminRequiredErrorNotAuthorizedError
SelfManagedRequiredErrorNotAuthorizedError
SiteAdminOrPartnerAdminPermissionRequiredErrorNotAuthorizedError
SiteAdminOrWorkspaceAdminOrFolderAdminPermissionRequiredErrorNotAuthorizedError
SiteAdminOrWorkspaceAdminOrPartnerAdminOrFolderAdminPermissionRequiredErrorNotAuthorizedError
SiteAdminOrWorkspaceAdminOrPartnerAdminPermissionRequiredErrorNotAuthorizedError
SiteAdminOrWorkspaceAdminPermissionRequiredErrorNotAuthorizedError
SiteAdminRequiredErrorNotAuthorizedError
SiteFilesAreImmutableErrorNotAuthorizedError
TwoFactorAuthenticationRequiredErrorNotAuthorizedError
UserIdWithoutSiteAdminErrorNotAuthorizedError
WriteAndBundlePermissionRequiredErrorNotAuthorizedError
WritePermissionRequiredErrorNotAuthorizedError
ApiKeyNotFoundErrorNotFoundError
BundlePathNotFoundErrorNotFoundError
BundleRegistrationNotFoundErrorNotFoundError
CodeNotFoundErrorNotFoundError
FileNotFoundErrorNotFoundError
FileUploadNotFoundErrorNotFoundError
GroupNotFoundErrorNotFoundError
InboxNotFoundErrorNotFoundError
NestedNotFoundErrorNotFoundError
PlanNotFoundErrorNotFoundError
SiteNotFoundErrorNotFoundError
UserNotFoundErrorNotFoundError
AgentPushUpdateBlockedErrorProcessingFailureError
AgentUnavailableErrorProcessingFailureError
AiTaskCannotBeRunManuallyErrorProcessingFailureError
AlreadyCompletedErrorProcessingFailureError
AutomationCannotBeRunManuallyErrorProcessingFailureError
BehaviorNotAllowedOnRemoteServerErrorProcessingFailureError
BufferedUploadDisabledForThisDestinationErrorProcessingFailureError
BundleOnlyAllowsPreviewsErrorProcessingFailureError
BundleOperationRequiresSubfolderErrorProcessingFailureError
ConfigurationLockedPathErrorProcessingFailureError
CouldNotCreateParentErrorProcessingFailureError
DestinationExistsErrorProcessingFailureError
DestinationFolderLimitedErrorProcessingFailureError
DestinationParentConflictErrorProcessingFailureError
DestinationParentDoesNotExistErrorProcessingFailureError
ExceededRuntimeLimitErrorProcessingFailureError
ExpectationAlreadyHasOpenWindowErrorProcessingFailureError
ExpectationNotManualTriggerErrorProcessingFailureError
ExpiredPrivateKeyErrorProcessingFailureError
ExpiredPublicKeyErrorProcessingFailureError
ExportFailureErrorProcessingFailureError
ExportNotReadyErrorProcessingFailureError
FailedToChangePasswordErrorProcessingFailureError
FileLockedErrorProcessingFailureError
FileNotUploadedErrorProcessingFailureError
FilePendingProcessingErrorProcessingFailureError
FileProcessingErrorErrorProcessingFailureError
FileTooBigToDecryptErrorProcessingFailureError
FileTooBigToEncryptErrorProcessingFailureError
FileUploadedToWrongRegionErrorProcessingFailureError
FilenameTooLongErrorProcessingFailureError
FolderLockedErrorProcessingFailureError
FolderNotEmptyErrorProcessingFailureError
HistoryUnavailableErrorProcessingFailureError
InvalidBundleCodeErrorProcessingFailureError
InvalidFileTypeErrorProcessingFailureError
InvalidFilenameErrorProcessingFailureError
InvalidPriorityColorErrorProcessingFailureError
InvalidRangeErrorProcessingFailureError
InvalidSiteErrorProcessingFailureError
InvalidZipFileErrorProcessingFailureError
MetadataNotSupportedOnRemotesErrorProcessingFailureError
ModelSaveErrorErrorProcessingFailureError
MultipleProcessingErrorsErrorProcessingFailureError
PathTooLongErrorProcessingFailureError
RecipientAlreadySharedErrorProcessingFailureError
RemoteEntryReadOnlyErrorProcessingFailureError
RemoteServerErrorErrorProcessingFailureError
ResourceBelongsToParentSiteErrorProcessingFailureError
ResourceLockedErrorProcessingFailureError
SubfolderLockedErrorProcessingFailureError
SyncInProgressErrorProcessingFailureError
TwoFactorAuthenticationCodeAlreadySentErrorProcessingFailureError
TwoFactorAuthenticationCountryBlacklistedErrorProcessingFailureError
TwoFactorAuthenticationGeneralErrorErrorProcessingFailureError
TwoFactorAuthenticationMethodUnsupportedErrorErrorProcessingFailureError
TwoFactorAuthenticationUnsubscribedRecipientErrorProcessingFailureError
UpdatesNotAllowedForRemotesErrorProcessingFailureError
DuplicateShareRecipientErrorRateLimitedError
ReauthenticationRateLimitedErrorRateLimitedError
TooManyConcurrentLoginsErrorRateLimitedError
TooManyConcurrentRequestsErrorRateLimitedError
TooManyLoginAttemptsErrorRateLimitedError
TooManyRequestsErrorRateLimitedError
TooManySharesErrorRateLimitedError
AutomationsUnavailableErrorServiceUnavailableError
LockOperationBusyErrorServiceUnavailableError
MigrationInProgressErrorServiceUnavailableError
SearchUnavailableErrorServiceUnavailableError
SiteDisabledErrorServiceUnavailableError
UploadsUnavailableErrorServiceUnavailableError
AccountAlreadyExistsErrorSiteConfigurationError
AccountOverdueErrorSiteConfigurationError
NoAccountForSiteErrorSiteConfigurationError
SiteWasRemovedErrorSiteConfigurationError
TrialExpiredErrorSiteConfigurationError
TrialLockedErrorSiteConfigurationError
UserRequestsEnabledRequiredErrorSiteConfigurationError