Errors

The Files.com PHP 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. The message of an exception for an HTTP error response, from getMessage(), names the request's method and HTTP status, and for an API error its type; it never quotes the response body or the request URL, which can contain credentials. The message of a transport error has the request URL replaced with [redacted]. API exceptions provide the API's own error message and details through getError(), getTitle() and the other getters listed below.

Use standard PHP exception handling to detect and deal with errors. It is generally recommended to catch specific errors first, then catch the general Files\Exception\FilesException exception as a catch-all.

Example Error Handling

try {
  $session = Files\Model\Session::create(['username' => 'USERNAME', 'password' => 'BADPASSWORD']);
} catch (\Files\Exception\NotAuthenticatedException $e) {
  echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\Exception\FilesException $e) {
  echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}

Error Types

SDK Errors

SDK errors are general errors that occur within the SDK code. These errors generate exceptions. Each of these exception classes inherit from a standard Exception base class.

The Api* exceptions below extend ApiConnectionException, which classifies how a request the SDK sent failed, apart from an API error: the API could not be reached, the HTTP client failed, the API answered with a 5xx status, or the SDK could not use the response.

Example SDK Exception Class Inheritance Structure

Files\Exception\ApiConnectException ->
Files\Exception\ApiConnectionException ->
Files\Exception\FilesException ->
Exception

SDK Exception Classes

Exception Class NameDescription
ApiConnectionExceptionThe parent of the Api* exceptions below
ApiBadResponseExceptionThe SDK could not use the response, such as an HTTP error status below 500 without a readable Files.com error object, a model that is not a JSON object, a list that is not a JSON array, or a list cursor that was already followed
ApiConnectExceptionThe Files.com API cannot be reached, or the request timed out
ApiRequestExceptionThe HTTP client could not complete the request, for example because of a TLS error
ApiServerExceptionThe API service answered with a 5xx status, whatever the response body holds
ApiTooManyRedirectsExceptionThe API service redirected too many times
ApiTransferExceptionThe HTTP client failed to transfer the request
ConfigurationExceptionInvalid SDK configuration parameters
EmptyPropertyExceptionAn required property was empty
InvalidParameterExceptionA passed in parameter is invalid
MissingParameterExceptionA method parameter is missing
NotImplementedExceptionThe called method has not be implemented by the SDK

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.

An HTTP error response with a status below 500 whose body is a Files.com error object raises the exception class its type names, or ApiException itself for a type the SDK does not recognize. The getters getType(), getError(), getTitle(), getHttpCode(), getDetail(), getErrors() and getData() return the error object's fields, or null for a field it does not include.

Example API Exception Class Inheritance Structure

Files\Exception\NotAuthorized\FolderAdminPermissionRequiredException ->
Files\Exception\NotAuthorizedException ->
Files\Exception\ApiException ->
Files\Exception\FilesException ->
Exception

API Exception Classes

Exception Class NameError Group
AgentUpgradeRequiredExceptionBadRequestException
AttachmentTooLargeExceptionBadRequestException
CannotDownloadDirectoryExceptionBadRequestException
CantMoveWithMultipleLocationsExceptionBadRequestException
DatetimeParseExceptionBadRequestException
DestinationSameExceptionBadRequestException
DestinationSiteMismatchExceptionBadRequestException
DoesNotSupportSortingExceptionBadRequestException
FolderMustNotBeAFileExceptionBadRequestException
FoldersNotAllowedExceptionBadRequestException
InternalGeneralErrorExceptionBadRequestException
InvalidBodyExceptionBadRequestException
InvalidCursorExceptionBadRequestException
InvalidCursorTypeForSortExceptionBadRequestException
InvalidEtagsExceptionBadRequestException
InvalidFilterAliasCombinationExceptionBadRequestException
InvalidFilterFieldExceptionBadRequestException
InvalidFilterParamExceptionBadRequestException
InvalidFilterParamFormatExceptionBadRequestException
InvalidFilterParamValueExceptionBadRequestException
InvalidInputEncodingExceptionBadRequestException
InvalidInterfaceExceptionBadRequestException
InvalidOauthProviderExceptionBadRequestException
InvalidPathExceptionBadRequestException
InvalidReturnToUrlExceptionBadRequestException
InvalidSearchQueryExceptionBadRequestException
InvalidSortFieldExceptionBadRequestException
InvalidSortFilterCombinationExceptionBadRequestException
InvalidUploadOffsetExceptionBadRequestException
InvalidUploadPartGapExceptionBadRequestException
InvalidUploadPartSizeExceptionBadRequestException
InvalidWorkspaceIdHeaderExceptionBadRequestException
MethodNotAllowedExceptionBadRequestException
MultipleSortParamsNotAllowedExceptionBadRequestException
NoValidInputParamsExceptionBadRequestException
OffsetUploadNotAllowedWithMalwareScanningExceptionBadRequestException
PartNumberTooLargeExceptionBadRequestException
PathCannotHaveTrailingWhitespaceExceptionBadRequestException
ReauthenticationNeededFieldsExceptionBadRequestException
RequestBodyTooLargeExceptionBadRequestException
RequestParamsContainInvalidCharacterExceptionBadRequestException
RequestParamsInvalidExceptionBadRequestException
RequestParamsRequiredExceptionBadRequestException
SearchAllOnChildPathExceptionBadRequestException
UnrecognizedSortIndexExceptionBadRequestException
UnsupportedCurrencyExceptionBadRequestException
UnsupportedHttpResponseFormatExceptionBadRequestException
UnsupportedMediaTypeExceptionBadRequestException
UserIdInvalidExceptionBadRequestException
UserIdOnUserEndpointExceptionBadRequestException
UserRequiredExceptionBadRequestException
AdditionalAuthenticationRequiredExceptionNotAuthenticatedException
ApiKeySessionsNotSupportedExceptionNotAuthenticatedException
AuthenticationRequiredExceptionNotAuthenticatedException
BundleRegistrationCodeFailedExceptionNotAuthenticatedException
InboxRegistrationCodeFailedExceptionNotAuthenticatedException
InvalidCredentialsExceptionNotAuthenticatedException
InvalidOauthExceptionNotAuthenticatedException
InvalidOrExpiredCodeExceptionNotAuthenticatedException
InvalidSessionExceptionNotAuthenticatedException
InvalidUsernameOrPasswordExceptionNotAuthenticatedException
LockedOutExceptionNotAuthenticatedException
LockoutRegionMismatchExceptionNotAuthenticatedException
OneTimePasswordIncorrectExceptionNotAuthenticatedException
TwoFactorAuthenticationErrorExceptionNotAuthenticatedException
TwoFactorAuthenticationSetupExpiredExceptionNotAuthenticatedException
ApiKeyIsDisabledExceptionNotAuthorizedException
ApiKeyIsPathRestrictedExceptionNotAuthorizedException
ApiKeyOnlyForDesktopAppExceptionNotAuthorizedException
ApiKeyOnlyForFileOperationsExceptionNotAuthorizedException
ApiKeyOnlyForMobileAppExceptionNotAuthorizedException
ApiKeyOnlyForOfficeIntegrationExceptionNotAuthorizedException
BillingInformationHiddenExceptionNotAuthorizedException
BillingPermissionRequiredExceptionNotAuthorizedException
BundleMaximumUsesReachedExceptionNotAuthorizedException
BundlePermissionRequiredExceptionNotAuthorizedException
CannotAdministerHigherLevelUserExceptionNotAuthorizedException
CannotLoginWhileUsingKeyExceptionNotAuthorizedException
CantActForOtherUserExceptionNotAuthorizedException
ContactAdminForPasswordChangeHelpExceptionNotAuthorizedException
FilesAgentFailedAuthorizationExceptionNotAuthorizedException
FolderAdminOrBillingPermissionRequiredExceptionNotAuthorizedException
FolderAdminPermissionRequiredExceptionNotAuthorizedException
FullPermissionRequiredExceptionNotAuthorizedException
HistoryPermissionRequiredExceptionNotAuthorizedException
InAppAiAssistantUnavailableExceptionNotAuthorizedException
InsufficientPermissionForParamsExceptionNotAuthorizedException
InsufficientPermissionForSiteExceptionNotAuthorizedException
MoverAccessDeniedExceptionNotAuthorizedException
MoverPackageRequiredExceptionNotAuthorizedException
MustAuthenticateWithApiKeyExceptionNotAuthorizedException
NeedAdminPermissionForInboxExceptionNotAuthorizedException
NonAdminsMustQueryByFolderOrPathExceptionNotAuthorizedException
NotAllowedToCreateBundleExceptionNotAuthorizedException
NotEnqueuableSyncExceptionNotAuthorizedException
PasswordChangeNotRequiredExceptionNotAuthorizedException
PasswordChangeRequiredExceptionNotAuthorizedException
PaymentMethodErrorExceptionNotAuthorizedException
PreviewOnlyPermissionCannotDownloadExceptionNotAuthorizedException
ReadOnlySessionExceptionNotAuthorizedException
ReadPermissionRequiredExceptionNotAuthorizedException
ReauthenticationFailedExceptionNotAuthorizedException
ReauthenticationFailedFinalExceptionNotAuthorizedException
ReauthenticationNeededActionExceptionNotAuthorizedException
RecaptchaFailedExceptionNotAuthorizedException
RemoteDesktopDebugLoggingDisabledExceptionNotAuthorizedException
RootFolderBehaviorSiteAdminRequiredExceptionNotAuthorizedException
RootFolderBehaviorSkipSiteAdminRequiredExceptionNotAuthorizedException
SelfManagedRequiredExceptionNotAuthorizedException
SiteAdminOrPartnerAdminPermissionRequiredExceptionNotAuthorizedException
SiteAdminOrWorkspaceAdminOrFolderAdminPermissionRequiredExceptionNotAuthorizedException
SiteAdminOrWorkspaceAdminOrPartnerAdminOrFolderAdminPermissionRequiredExceptionNotAuthorizedException
SiteAdminOrWorkspaceAdminOrPartnerAdminPermissionRequiredExceptionNotAuthorizedException
SiteAdminOrWorkspaceAdminPermissionRequiredExceptionNotAuthorizedException
SiteAdminRequiredExceptionNotAuthorizedException
SiteFilesAreImmutableExceptionNotAuthorizedException
TwoFactorAuthenticationRequiredExceptionNotAuthorizedException
UserIdWithoutSiteAdminExceptionNotAuthorizedException
WriteAndBundlePermissionRequiredExceptionNotAuthorizedException
WritePermissionRequiredExceptionNotAuthorizedException
ApiKeyNotFoundExceptionNotFoundException
BundlePathNotFoundExceptionNotFoundException
BundleRegistrationNotFoundExceptionNotFoundException
CodeNotFoundExceptionNotFoundException
FileNotFoundExceptionNotFoundException
FileUploadNotFoundExceptionNotFoundException
GroupNotFoundExceptionNotFoundException
InboxNotFoundExceptionNotFoundException
NestedNotFoundExceptionNotFoundException
PlanNotFoundExceptionNotFoundException
SiteNotFoundExceptionNotFoundException
UserNotFoundExceptionNotFoundException
AgentPushUpdateBlockedExceptionProcessingFailureException
AgentUnavailableExceptionProcessingFailureException
AiTaskCannotBeRunManuallyExceptionProcessingFailureException
AlreadyCompletedExceptionProcessingFailureException
AutomationCannotBeRunManuallyExceptionProcessingFailureException
BehaviorNotAllowedOnRemoteServerExceptionProcessingFailureException
BufferedUploadDisabledForThisDestinationExceptionProcessingFailureException
BundleOnlyAllowsPreviewsExceptionProcessingFailureException
BundleOperationRequiresSubfolderExceptionProcessingFailureException
ConfigurationLockedPathExceptionProcessingFailureException
CouldNotCreateParentExceptionProcessingFailureException
DestinationExistsExceptionProcessingFailureException
DestinationFolderLimitedExceptionProcessingFailureException
DestinationParentConflictExceptionProcessingFailureException
DestinationParentDoesNotExistExceptionProcessingFailureException
ExceededRuntimeLimitExceptionProcessingFailureException
ExpectationAlreadyHasOpenWindowExceptionProcessingFailureException
ExpectationNotManualTriggerExceptionProcessingFailureException
ExpiredPrivateKeyExceptionProcessingFailureException
ExpiredPublicKeyExceptionProcessingFailureException
ExportFailureExceptionProcessingFailureException
ExportNotReadyExceptionProcessingFailureException
FailedToChangePasswordExceptionProcessingFailureException
FileLockedExceptionProcessingFailureException
FileNotUploadedExceptionProcessingFailureException
FilePendingProcessingExceptionProcessingFailureException
FileProcessingErrorExceptionProcessingFailureException
FileTooBigToDecryptExceptionProcessingFailureException
FileTooBigToEncryptExceptionProcessingFailureException
FileUploadedToWrongRegionExceptionProcessingFailureException
FilenameTooLongExceptionProcessingFailureException
FolderLockedExceptionProcessingFailureException
FolderNotEmptyExceptionProcessingFailureException
HistoryUnavailableExceptionProcessingFailureException
InvalidBundleCodeExceptionProcessingFailureException
InvalidFileTypeExceptionProcessingFailureException
InvalidFilenameExceptionProcessingFailureException
InvalidPriorityColorExceptionProcessingFailureException
InvalidRangeExceptionProcessingFailureException
InvalidSiteExceptionProcessingFailureException
InvalidZipFileExceptionProcessingFailureException
MetadataNotSupportedOnRemotesExceptionProcessingFailureException
ModelSaveErrorExceptionProcessingFailureException
MultipleProcessingErrorsExceptionProcessingFailureException
PathTooLongExceptionProcessingFailureException
RecipientAlreadySharedExceptionProcessingFailureException
RemoteEntryReadOnlyExceptionProcessingFailureException
RemoteServerErrorExceptionProcessingFailureException
ResourceBelongsToParentSiteExceptionProcessingFailureException
ResourceLockedExceptionProcessingFailureException
SubfolderLockedExceptionProcessingFailureException
SyncInProgressExceptionProcessingFailureException
TwoFactorAuthenticationCodeAlreadySentExceptionProcessingFailureException
TwoFactorAuthenticationCountryBlacklistedExceptionProcessingFailureException
TwoFactorAuthenticationGeneralErrorExceptionProcessingFailureException
TwoFactorAuthenticationMethodUnsupportedErrorExceptionProcessingFailureException
TwoFactorAuthenticationUnsubscribedRecipientExceptionProcessingFailureException
UpdatesNotAllowedForRemotesExceptionProcessingFailureException
DuplicateShareRecipientExceptionRateLimitedException
FilesNativeStorageOverloadedExceptionRateLimitedException
ReauthenticationRateLimitedExceptionRateLimitedException
TooManyConcurrentLoginsExceptionRateLimitedException
TooManyConcurrentRequestsExceptionRateLimitedException
TooManyLoginAttemptsExceptionRateLimitedException
TooManyRequestsExceptionRateLimitedException
TooManySharesExceptionRateLimitedException
AutomationsUnavailableExceptionServiceUnavailableException
LockOperationBusyExceptionServiceUnavailableException
MigrationInProgressExceptionServiceUnavailableException
SearchUnavailableExceptionServiceUnavailableException
SiteDisabledExceptionServiceUnavailableException
UploadsUnavailableExceptionServiceUnavailableException
AccountAlreadyExistsExceptionSiteConfigurationException
AccountOverdueExceptionSiteConfigurationException
NoAccountForSiteExceptionSiteConfigurationException
SiteWasRemovedExceptionSiteConfigurationException
TrialExpiredExceptionSiteConfigurationException
TrialLockedExceptionSiteConfigurationException
UserRequestsEnabledRequiredExceptionSiteConfigurationException