Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error responses on github loc API #28

Open
Cryp70m4n opened this issue Feb 26, 2023 · 1 comment
Open

Improve error responses on github loc API #28

Cryp70m4n opened this issue Feb 26, 2023 · 1 comment

Comments

@Cryp70m4n
Copy link

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 Cryp70m4n changed the title Add better errors on github loc API Add better error responses on github loc API Feb 26, 2023
@Cryp70m4n Cryp70m4n changed the title Add better error responses on github loc API Improve error responses on github loc API Feb 26, 2023
jolav added a commit that referenced this issue Feb 26, 2023
@jolav
Copy link
Owner

jolav commented Feb 26, 2023

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
 }
]

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

No branches or pull requests

2 participants