public GlobalXApiTokenLockIdMismatchException( GlobalXApiTokenLockInfo existingLock, GlobalXApiTokenLockInfo lockInfoSuppliedWithRequest, GlobalXApiToken globalXApiToken) : base($"An attempt was made to update GlobalXApiToken for user '{globalXApiToken?.UserId}'," + $" however the lock ID supplied was '{lockInfoSuppliedWithRequest?.LockId}'" + $" which doesn't match the existing lock of '{existingLock?.LockId}'.") { ExistingLock = existingLock; LockInfo = lockInfoSuppliedWithRequest; GlobalXApiToken = globalXApiToken; }
/// <summary> /// Thrown when and error is received attempting to retrieve a token. /// </summary> /// <param name="apiToken"></param> /// <param name="response"></param> /// <param name="statusCode"></param> /// <param name="receivedAt"></param> public RefreshGlobalXApiTokenErrorResponseException(GlobalXApiToken apiToken, JObject response, HttpStatusCode statusCode, Instant receivedAt) : base(CreateDefaultMessage(apiToken, statusCode, response)) { GlobalXApiToken = apiToken; StatusCode = statusCode; ReceivedAt = receivedAt; if (!(response is null)) { Response = response; RemoteError = response.Value <string>("error"); } }
private static string CreateDefaultMessage(GlobalXApiToken apiToken, HttpStatusCode httpStatusCode, JObject response) { var friendlyStatusCode = $"{(int)httpStatusCode} {httpStatusCode.ToString()}"; if (response is null) { return($"GlobalX returned an error status code '{friendlyStatusCode}' when attempting to refresh the tokenSet for user '{apiToken?.UserId}'. The response was empty."); } else { var remoteError = response.Value <string>("error") ?? "null"; var remoteErrorDescription = response.Value <string>("error_description") ?? "null"; var remoteErrorUri = response.Value <string>("error_uri") ?? "null"; return($"GlobalX returned an error status code '{friendlyStatusCode}' when attempting to refresh a tokenSet." + $", User ID : '{apiToken?.UserId}'." + $", Remote error:'{remoteError}'" + $", error_description: '{remoteErrorDescription}'" + $", and error_uri: '{remoteErrorUri}'"); } }
public CannotUpdateGlobalXApiTokenWithoutLockException(GlobalXApiToken apiToken) : base("Cannot update GlobalXApiToken because a lock was not provided first." + $" The token belongs to user with ID: '{apiToken?.UserId}'.") { ApiToken = apiToken; }
public InvalidGlobalXApiTokenException(string message, GlobalXApiToken apiToken) : base(message) { ApiToken = apiToken; }
public InvalidGlobalXApiTokenException(GlobalXApiToken apiToken) { ApiToken = apiToken; }