Skip to content

Instantly share code, notes, and snippets.

@thedavecarroll
Last active May 29, 2021 12:59
Show Gist options
  • Save thedavecarroll/a551d146a382c5e04d2daaaa59421717 to your computer and use it in GitHub Desktop.
Save thedavecarroll/a551d146a382c5e04d2daaaa59421717 to your computer and use it in GitHub Desktop.
Twitter API Error Mapping
@{
'1.1' = @{
'400' = @{
OperationStopped = 324
ObjectNotFound = 325
InvalidOperation = 323, 110
AuthenticationError = 215
InvalidArgument = 3, 7, 8, 44
ResourceUnavailable = 407
}
'401' = @{
AuthenticationError = 417, 135, 32, 416
}
'403' = @{
SecurityError = 326
InvalidOperation = 200, 272, 160, 203, 431
QuotaExceeded = 386, 205, 226, 327
AuthenticationError = 99, 89
ConnectionError = 195, 92
InvalidArgument = 354, 186, 38, 120, 163
PermissionDenied = 214, 220, 261, 187, 349, 385, 415, 271, 185, 36, 63, 64, 87, 179, 93, 433, 139, 150, 151, 161, 425
}
'404' = @{
ObjectNotFound = 34, 108, 109, 422, 421, 13, 17, 144, 34, 50
InvalidArgument = 25
}
'406' = @{
InvalidData = $null
}
'409' = @{
InvalidOperation = 355
}
'410' = @{
ConnectionError = 68
NotImplemented = 251
}
'415' = @{
LimitsExceeded = $null
Message = 'Message size exceeds limits of 10000 characters.'
}
'420' = @{
QuotaExceeded = $null
}
'422' = @{
InvalidArgument = $null
InvalidOperation = 404
}
'429' = @{
QuotaExceeded = 88
}
'500' = @{
ResourceUnavailable = 131
}
'503' = @{
ResourceBusy = 130
}
}
'2' = @{
'about:blank' = 'NotSpecified'
'https://api.twitter.com/2/problems/not-authorized-for-resource' = 'PermissionDenied'
'https://api.twitter.com/2/problems/not-authorized-for-field' = 'PermissionDenied'
'https://api.twitter.com/2/problems/invalid-request' = 'InvalidArgument'
'https://api.twitter.com/2/problems/client-forbidden' = 'PermissionDenied'
'https://api.twitter.com/2/problems/disallowed-resource' = 'PermissionDenied'
'https://api.twitter.com/2/problems/unsupported-authentication' = 'AuthenticationError'
'https://api.twitter.com/2/problems/usage-capped' = 'QuotaExceeded'
'https://api.twitter.com/2/problems/streaming-connection' = 'ConnectionError'
'https://api.twitter.com/2/problems/client-disconnected' = 'ConnectionError'
'https://api.twitter.com/2/problems/operational-disconnect' = 'ResourceUnavailable'
'https://api.twitter.com/2/problems/rule-cap' = 'QuotaExceeded'
'https://api.twitter.com/2/problems/invalid-rules' = 'InvalidArgument'
'https://api.twitter.com/2/problems/duplicate-rules' = 'InvalidOperation'
}
}
@thedavecarroll
Copy link
Author

Originally, I was going to use the file TwitterErrorMapping.psd1 to map the returned errors. I soon realized that using the switch statement as I did in Get-ErrorCategory.ps1 was much simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment