• Guides
  • API Documentation
  • Changelog
Show / Hide Table of Contents
  • Basic Guides
    • Introduction
    • Supported endpoints
    • Exception handling
  • Advanced Guides
    • Caching
    • Response info
    • Last-Modified
    • Middleware
    • Proxying the API
    • Subtokens
    • Debug symbols
  • Tips
    • Using RenderUrl

Exception handling

Gw2Sharp aims to be as friendly as possible when unexpected status codes are received from the Guild Wars 2 API. Whenever a request fails, a custom exception will be thrown for you to catch.

The following exceptions can be thrown from Gw2Sharp:

  • RequestException: An exception occured during the request
    • RequestCanceledException: The request has been canceled
    • UnexpectedStatusException: An unexpected HTTP status code was returned from the server
      • BadRequestException (400): The client sent an invalid request
        • ListTooLongException (400): The list of requested resources is too long
        • PageOutOfRangeException (400): The requested page is out of range
      • AuthorizationRequiredException (401, 403): The client is unauthorized
        • InvalidAccessTokenException (401, 403): The access token is invalid
        • MissingScopesException (403): The access token does not have the required scopes
        • MembershipRequiredException (403): The user is not a member of the guild
        • RestrictedToGuildLeadersException (403): The user is not a leader of the guild
      • NotFoundException (404): The requested resource has not been found
      • TooManyRequestsException (429): Too many requests have been issued in a short period of time
      • ServerErrorException (500): The server encountered an error
      • ServiceUnavailableException (503): The server is temporarily unavailable
Tip

As you can see, all custom exceptions inherit from RequestException. This makes it easier to have a generic catch-all statement for Gw2Sharp. However, certain exceptions may provide extra details as to why it has occured. If you need that information, it's recommended to catch the specific exceptions first, before the more generic ones.

  • Improve this Doc
In This Article
Back to top Generated by DocFX