The API documentation provides us with a list of error codes, but I ran into a "warning" while looking up the "torn" category with nothing specified for a selection.
{"code":1,"warning":"No default selection for this type"} Are there any other warnings we can look out for, for the purposes of error handling? Thanks.
Is this what you mean? 0 => 'Unknown error' : Unhandled error, should not occur. 1 => 'Key is empty' : Private key is empty in current request. 2 => 'Incorrect Key' : Private key is wrong/incorrect format. 3 => 'Wrong type' : Requesting an incorrect basic type. 4 => 'Wrong fields' : Requesting incorrect selection fields. 5 => 'Too many requests' : Current private key is banned for a small period of time because of too many requests (max 100 per minute). 6 => 'Incorrect ID' : Wrong ID value. 7 => 'Incorrect ID-entity relation' : A requested selection is private (For example, personal data of another user / faction). 8 => 'IP block' : Current IP is banned for a small period of time because of abuse.
And why make it a warning instead of an error? Torn might handle them differently internally, but for public users of the API they are all errors-- no result was available.
You're just messing with the semantics at a different level, and every API call will have to check for both errors and warnings because of that.
Both "Well shit, something went wrong" and "You asked for something, but I don't have it" are errors at the API level-- there's no data returned and nothing you can do about it apart from doing a new call with correct parameters.
And also, using your logic 'wrong fields'/selections should be warnings instead of errors.