Download internal/httpapi/gemini/handler_errors.go from a3216/ds2api: direct link, hf CLI and curl.
- Browser
- Download file 631 Bytes
-
https://huggingface.co/spaces/a3216/ds2api/resolve/ce5a019598af8a3a8fa70d3880098df3e850ecd7/internal/httpapi/gemini/handler_errors.go
- Command line
-
hf download hf://spaces/a3216/ds2api@ce5a019598af8a3a8fa70d3880098df3e850ecd7/internal/httpapi/gemini/handler_errors.go
-
curl -L -o handler_errors.go https://huggingface.co/spaces/a3216/ds2api/resolve/ce5a019598af8a3a8fa70d3880098df3e850ecd7/internal/httpapi/gemini/handler_errors.go
631 Bytes
| package gemini | |
| import "net/http" | |
| func writeGeminiError(w http.ResponseWriter, status int, message string) { | |
| errorStatus := "INVALID_ARGUMENT" | |
| switch status { | |
| case http.StatusUnauthorized: | |
| errorStatus = "UNAUTHENTICATED" | |
| case http.StatusForbidden: | |
| errorStatus = "PERMISSION_DENIED" | |
| case http.StatusTooManyRequests: | |
| errorStatus = "RESOURCE_EXHAUSTED" | |
| case http.StatusNotFound: | |
| errorStatus = "NOT_FOUND" | |
| default: | |
| if status >= 500 { | |
| errorStatus = "INTERNAL" | |
| } | |
| } | |
| writeJSON(w, status, map[string]any{ | |
| "error": map[string]any{ | |
| "code": status, | |
| "message": message, | |
| "status": errorStatus, | |
| }, | |
| }) | |
| } | |