Errors

The Files.com .NET SDK reports errors by throwing 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.

Exception class names identify the error type. The exception's Message property provides error details.

Use .NET exception handling to handle errors. Catch specific exception types before SdkException.

Example Error Handling

using FilesCom.Models;

Dictionary<string, object> paramsDict = new Dictionary<string, object>();
paramsDict.Add("username", "USERNAME");
paramsDict.Add("password", "BADPASSWORD");
Session session;

try
{
    session = await Session.Create(paramsDict);
}
catch (FilesCom.NotAuthenticatedException e)
{
    Console.WriteLine($"Authentication Error Occurred ({e.GetType().Name}): " + e.Message);
}
catch (FilesCom.SdkException e)
{
    Console.WriteLine($"Unknown Error Occurred ({e.GetType().Name}): " + e.Message);
}

SDK Errors

SDK exceptions inherit from SdkException. Invalid SDK usage throws an exception before any request is sent.

Cancellation throws OperationCanceledException. Errors from streams you provide retain the stream's exception type.

Example SDK Exception Class Inheritance Structure

FilesCom.InvalidResponseException ->
FilesCom.ApiConnectionException ->
FilesCom.SdkException ->
Exception

SDK Exception Classes

Exception Class NameDescription
ApiConnectionExceptionThe Files.com API cannot be reached, or gave no reliable response
InvalidResponseExceptionAn ApiConnectionException for a response that could not be read, with its httpStatus and httpHeaders when it was an error response
AuthenticationExceptionThere is no API key or session ID for a request that needs one
MissingParameterExceptionA required parameter, or the ID of the object called, is missing
InvalidParameterExceptionA passed in parameter or option is invalid, such as a value of the wrong type
NotImplementedExceptionThe called method has not been 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.

The class comes from the error type in the response, never from its HTTP status. If the SDK has no class for the returned error type, it throws the error group's exception class, including NotFoundException, or ApiException if the group is unknown. Every API exception has the response's httpStatus, httpHeaders and error details, such as error and type. Its Message removes URL user information, query strings and fragments from the error text because these can contain signed URL credentials. The error property retains the original text.

Example API Exception Class Inheritance Structure

FilesCom.FolderAdminPermissionRequiredException ->
FilesCom.NotAuthorizedException ->
FilesCom.ApiException ->
FilesCom.SdkException ->
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
ReauthenticationRateLimitedExceptionRateLimitedException
TooManyConcurrentLoginsExceptionRateLimitedException
TooManyConcurrentRequestsExceptionRateLimitedException
TooManyLoginAttemptsExceptionRateLimitedException
TooManyRequestsExceptionRateLimitedException
TooManySharesExceptionRateLimitedException
AutomationsUnavailableExceptionServiceUnavailableException
LockOperationBusyExceptionServiceUnavailableException
MigrationInProgressExceptionServiceUnavailableException
SearchUnavailableExceptionServiceUnavailableException
SiteDisabledExceptionServiceUnavailableException
UploadsUnavailableExceptionServiceUnavailableException
AccountAlreadyExistsExceptionSiteConfigurationException
AccountOverdueExceptionSiteConfigurationException
NoAccountForSiteExceptionSiteConfigurationException
SiteWasRemovedExceptionSiteConfigurationException
TrialExpiredExceptionSiteConfigurationException
TrialLockedExceptionSiteConfigurationException
UserRequestsEnabledRequiredExceptionSiteConfigurationException