|
50 | 50 | methods(Static)
|
51 | 51 | % Convert a response to objects
|
52 | 52 | function objs = from(response)
|
53 |
| - assert(~isempty(response.results), 'the response contains no results'); |
54 |
| - objs = arrayfun(@(x) QueryResult.wrap(x), response.results); |
| 53 | + assert(~isempty(response.results), ... |
| 54 | + 'from:empty', 'the response contains no results'); |
| 55 | + objs = arrayfun(@(x) QueryResult.wrap(x), ... |
| 56 | + response.results, 'UniformOutput', false); |
| 57 | + nonempty = cellfun(@(x) ~isempty(x), objs); |
| 58 | + objs = cellfun(@(x) x, objs(nonempty)); |
55 | 59 | end
|
56 | 60 | end
|
57 | 61 |
|
|
61 | 65 | if isfield(result, 'error')
|
62 | 66 | error('query:error', 'query error: %s', result.error);
|
63 | 67 | end
|
64 |
| - assert(isfield(result, 'series'), 'the result contains no series'); |
65 |
| - series = arrayfun(@(x) SeriesResult.from(x), result.series); |
66 |
| - obj = QueryResult(series); |
| 68 | + if isfield(result, 'series') |
| 69 | + series = arrayfun(@(x) SeriesResult.from(x), result.series); |
| 70 | + obj = QueryResult(series); |
| 71 | + else |
| 72 | + obj = []; |
| 73 | + end |
67 | 74 | end
|
68 | 75 |
|
69 | 76 | % Filter series by matching tags
|
|
0 commit comments