Repository: sunpy/sunpy

Issue:
Cryptic error message when querying the HEK with a search that returns no results
<!-- This comments are hidden when you submit the issue so you do not need to remove them!
Please be sure to check out our contributing guidelines: https://github.com/sunpy/sunpy/blob/master/CONTRIBUTING.rst
Please be sure to check out our code of conduct:
https://github.com/sunpy/sunpy/blob/master/CODE_OF_CONDUCT.rst -->

<!-- Please have a search on our GitHub repository to see if a similar issue has already been posted.
If a similar issue is closed, have a quick look to see if you are satisfied by the resolution.
If not please go ahead and open an issue! -->

### Description
Cryptic error message when querying the HEK with a search that returns no results.

### Expected behavior
<!-- What did you expect to happen. -->
Rise a more informative error message or return an empty HEKTable

### Actual behavior
<!-- What actually happened. -->
<!-- Was the output confusing or poorly described? -->
Raises an unexpected error
```ValueError: Inconsistent data column lengths: set()```

### Steps to Reproduce
<!-- Ideally a code example could be provided so we can run it ourselves. -->
<!-- If you are pasting code, use tripe backticks (```) around your code snippet. -->

```
from sunpy.time import TimeRange
from sunpy.net import hek


client = hek.HEKClient()

tstart = '1985-05-03 00:00:00'
tend = '1985-05-04 00:00:00'

result = client.search(hek.attrs.Time(tstart, tend),
                       hek.attrs.EventType('FL'),
                       hek.attrs.OBS.Observatory == 'GOES')
```
### System Details
<!-- We at least need to know the SunPy version you are using. -->
<!-- We provide a short function in SunPy that will provide some of the below information. -->
<!-- It is sunpy.util.system_info(), this is optional but strongly recommended. -->

  - SunPy Version: sunpy-1.0.0.dev1274+gdc0c8cf4f.dist-info (I pip installed from master)
  - Python Version: 3.6.3
  - OS information: macOS 10.14.3
Cryptic error message when querying the HEK with a search that returns no results
<!-- This comments are hidden when you submit the issue so you do not need to remove them!
Please be sure to check out our contributing guidelines: https://github.com/sunpy/sunpy/blob/master/CONTRIBUTING.rst
Please be sure to check out our code of conduct:
https://github.com/sunpy/sunpy/blob/master/CODE_OF_CONDUCT.rst -->

<!-- Please have a search on our GitHub repository to see if a similar issue has already been posted.
If a similar issue is closed, have a quick look to see if you are satisfied by the resolution.
If not please go ahead and open an issue! -->

### Description
Cryptic error message when querying the HEK with a search that returns no results.

### Expected behavior
<!-- What did you expect to happen. -->
Rise a more informative error message or return an empty HEKTable

### Actual behavior
<!-- What actually happened. -->
<!-- Was the output confusing or poorly described? -->
Raises an unexpected error
```ValueError: Inconsistent data column lengths: set()```

### Steps to Reproduce
<!-- Ideally a code example could be provided so we can run it ourselves. -->
<!-- If you are pasting code, use tripe backticks (```) around your code snippet. -->

```
from sunpy.time import TimeRange
from sunpy.net import hek


client = hek.HEKClient()

tstart = '1985-05-03 00:00:00'
tend = '1985-05-04 00:00:00'

result = client.search(hek.attrs.Time(tstart, tend),
                       hek.attrs.EventType('FL'),
                       hek.attrs.OBS.Observatory == 'GOES')
```
### System Details
<!-- We at least need to know the SunPy version you are using. -->
<!-- We provide a short function in SunPy that will provide some of the below information. -->
<!-- It is sunpy.util.system_info(), this is optional but strongly recommended. -->

  - SunPy Version: sunpy-1.0.0.dev1274+gdc0c8cf4f.dist-info (I pip installed from master)
  - Python Version: 3.6.3
  - OS information: macOS 10.14.3


Discussion:
I'll have a go at fixing this one should be pretty straight forward. Any preferences on:
a) raising a meaningful exception or
b) returning an empty HEKTable if that's possible?
I would go with returning an empty table, I think if Fido does not find anything, it just returns an empty response. I feel we should do the same. 
I'll have a go at fixing this one should be pretty straight forward. Any preferences on:
a) raising a meaningful exception or
b) returning an empty HEKTable if that's possible?
I would go with returning an empty table, I think if Fido does not find anything, it just returns an empty response. I feel we should do the same. 

Resolving patch:
diff --git a/sunpy/net/hek/hek.py b/sunpy/net/hek/hek.py
--- a/sunpy/net/hek/hek.py
+++ b/sunpy/net/hek/hek.py
@@ -73,7 +73,11 @@ def _download(self, data):
             results.extend(result['result'])
 
             if not result['overmax']:
-                return HEKTable(results)
+                if len(results) > 0:
+                    return HEKTable(results)
+                else:
+                    return HEKTable()
+
             page += 1
 
     def search(self, *query):


Test patch:
diff --git a/sunpy/net/tests/test_hek.py b/sunpy/net/tests/test_hek.py
--- a/sunpy/net/tests/test_hek.py
+++ b/sunpy/net/tests/test_hek.py
@@ -116,6 +116,21 @@ def test_hek_client():
     assert type(hek_query) == sunpy.net.hek.hek.HEKTable
 
 
+@pytest.mark.remote_data
+def test_hek_empty_search_result():
+    startTime = '1985-05-04 00:00:00'
+    endTime = '1985-05-04 00:00:00'
+    eventType = 'FL'
+
+    hekTime = hek.attrs.Time(startTime, endTime)
+    hekEvent = hek.attrs.EventType(eventType)
+
+    h = hek.HEKClient()
+    hek_query = h.search(hekTime, hekEvent)
+    assert type(hek_query) == sunpy.net.hek.hek.HEKTable
+    assert len(hek_query) == 0
+
+
 @pytest.mark.remote_data
 def test_getitem(hek_client_creator):
     hc = hek_client_creator