Consistency in return values
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 20/100
- Issue 类型
- 重构
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- php
调研方向
检查整个类,尤其是搜索和浏览方法,并将它们当前的返回值与 issue 中描述的错误报告方法进行比较。首先就一个响应契约达成一致;完成意味着所有受影响的方法都一致地遵循该契约,同时不留下未解决的兼容性决策。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- PHP
- 星标
- 42
- 派生
- 9
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
BaseMax/GooglePlayWebServiceAPI 的其他 Issue
-
enhancement good first issue help wanted
难度 4/5 3-5 天 新手友好度 35/100
BaseMax/GooglePlayWebServiceAPI#29 · 19 条评论 ·
-
enhancement good first issue help wanted
BaseMax/GooglePlayWebServiceAPI#27 · 13 条评论 · 已指派 1 人 ·
查看 BaseMax/GooglePlayWebServiceAPI 的全部 Issue
相似的 Issue
-
sync-en
难度 1/5 1-3 小时 新手友好度 88/100
-
sync-en
难度 1/5 1-3 小时 新手友好度 88/100
-
Перевод устарел
难度 1/5 1-3 小时 新手友好度 88/100
-
priority: p3
难度 2/5 1-3 小时 新手友好度 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
难度 2/5 1-3 小时 新手友好度 78/100
nextcloud/fulltextsearch#1011 ·