Improved API error codes