Consistency in return values
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 20/100
- Tipo di issue
- Refactoring
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- php
- Ambito
- api, backend-api-design
Direzione di ricerca
Esamina l’intera classe, in particolare i metodi di ricerca e navigazione, e confronta i loro valori restituiti attuali con i metodi di segnalazione degli errori descritti nell’issue. Per prima cosa raggiungi un accordo su un unico contratto di risposta; il lavoro è concluso quando tutti i metodi interessati seguono quel contratto in modo coerente, senza lasciare irrisolta la decisione sulla compatibilità.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
During my recent implementations and rewrites, I've introduced some "error reporting" to make it easier for the caller to figure if and what might have gone wrong. On error, several methods now return an array like
[success:0, message:"reason"]
But not all of them – for example, most of the search/browse methods supposed to return a simple array of package names don't have this. There would be two options to reach (a sort of) consistency:
- returning
[success:0, message:reason]instead (and if so, includesuccess:1with a "good result) also for those methods that currently do not, moving the "real results" into a "sub-array" (which then, on error, could be empty or just not present at all) - simply returning an empty array, and have a
getLastError()method for obtaining the reason for all search/browse methods while keeping the current behavior for the others.
I'd prefer the first approach (so it's completely consistent) with the "empty real result". This combines the best of two worlds, e.g.
$apps = $google->parseWhatever();
if ( empty($apps['data']) ) { // this could simply mean nothing found matching the criteria
if ( $apps['success'] ) { log('nothing found'); }
else { log ('ERROR occured: '.$apps['message']); }
} else { // do something with the data
I'd even go as far as to always include the message key, just leaving its value empty on success. That would make things most consistent.
What's your stance? If you agree, I'd go over the entire class another time and make it consistent:
success:0only on errors – not generally on "no results" for a user-specified search (I vaguely remember I accidentally made it such in one case).messagethen holds the reason (e.g. the HTTP response, or parse error when an expected pattern didn't match, etc)success:1on success.messagethen is present but usually empty, but might eg hold a hint on why the result set is empty (like "no hits").
If we want to fix it, we want to do that as early as possible – before there are users whose code would otherwise break on some update.
- Lingua principale
- PHP
- Stelle
- 42
- Fork
- 9
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di BaseMax/GooglePlayWebServiceAPI
-
enhancement good first issue help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
BaseMax/GooglePlayWebServiceAPI#29 · 19 commenti ·
-
Fetch reviews of an app Apertaenhancement good first issue help wanted
BaseMax/GooglePlayWebServiceAPI#27 · 13 commenti · 1 assegnatario ·
Tutte le issue di BaseMax/GooglePlayWebServiceAPI
Issue simili
-
[Chore] Keep one viget-block-generator skill and replicate it, instead of four tracked copies Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
hector-jewell/food-delivery-system-for-restaurant-using-php#1311 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
Sylius/SyliusGridBundle#501 ·