codetabs icon indicating copy to clipboard operation
codetabs copied to clipboard

Improve error responses on github loc API

Open Cryp70m4n opened this issue 3 years ago • 1 comments

Hello, I'm currently writing an browser extension and I decided to use codetabs API "https://api.codetabs.com/v1/loc/?github=" and I came across an idea which would help developers while using codetabs API. if you try to check "https://api.codetabs.com/v1/loc/?github=torvalds/linux" and "https://api.codetabs.com/v1/loc/?github=cryp70m4n/something" you get same JSON response format but different error message {"Error:": "Some error"}. Based on this fact I was thinking it would be nice if your API had some way for an end-developer to be able to find out what was the error without parsing every possible error message that could occur. For example you could add something like this {"Error": "Some error", "ErrorCode": -2} and based on this error code we could know if we were rated limited, repository was too big, repository doesn't exist, etc,... You could easily implement that and then write description of each error code in documentation.

Thanks.

Cryp70m4n avatar Feb 26 '23 12:02 Cryp70m4n

Thanks to this issue i have discovered a bug. Its fixed.

https://api.codetabs.com/v1/loc/?github=torvalds/linux returns Error | "repo torvalds/linux too big (>500MB) = 4334 MB"

https://api.codetabs.com/v1/loc/?github=cryp70m4n/proxymanworks for me possibly due to the bug fixed

[
 {
  "language": "Python",
  "files": 8,
  "lines": 350,
  "blanks": 52,
  "comments": 9,
  "linesOfCode": 289
 },
 {
  "language": "JSON",
  "files": 1,
  "lines": 7,
  "blanks": 0,
  "comments": 0,
  "linesOfCode": 7
 },
 {
  "language": "License",
  "files": 1,
  "lines": 339,
  "blanks": 58,
  "comments": 0,
  "linesOfCode": 281
 },
 {
  "language": "Markdown",
  "files": 1,
  "lines": 28,
  "blanks": 12,
  "comments": 0,
  "linesOfCode": 16
 },
 {
  "language": "Total",
  "files": 11,
  "lines": 724,
  "blanks": 122,
  "comments": 9,
  "linesOfCode": 593
 }
]

jolav avatar Feb 26 '23 22:02 jolav