feat(simkl): add comprehensive error handling
SimklFunctions.go: - Update SimklHelper to return (json.RawMessage, error) - Add status code validation (200-299 range) - Update SimklGetUserWatchlist to return (SimklWatchListType, error) - Update SimklSyncEpisodes to return (SimklAnime, error) - Update SimklSyncRating to return (SimklAnime, error) - Update SimklSyncStatus to return (SimklAnime, error) - Update SimklSearch to return (SimklAnime, error) - Update SimklSyncRemove to return (bool, error) - Add proper error wrapping for all failure scenarios SimklUserFunctions.go: - Replace log.Fatalf with log.Printf in server error handling (line 119) - Replace log.Fatal with log.Printf in JSON marshaling (line 141) All Simkl API calls now properly propagate errors to frontend.
This commit is contained in:
@@ -116,7 +116,7 @@ func (a *App) handleSimklCallback(wg *sync.WaitGroup) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Fatalf("listen: %s\n", err)
|
||||
log.Printf("Server error: %s\n", err)
|
||||
}
|
||||
fmt.Println("Shutting down...")
|
||||
}()
|
||||
@@ -138,7 +138,8 @@ func getSimklAuthorizationToken(content string) SimklJWT {
|
||||
}
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Printf("Failed to marshal data: %s\n", err)
|
||||
return SimklJWT{}
|
||||
}
|
||||
|
||||
response, err := http.NewRequest("POST", "https://api.simkl.com/oauth/token", bytes.NewBuffer(jsonData))
|
||||
|
||||
Reference in New Issue
Block a user