Repository: frictionlessdata/goodtables-py

Issue:
Catch jsontableschema.exceptions.InvalidJSONError
# Overview

For `table` and `datapackage` datasets it has to be caught. See - https://sentry.io/open-knowledge/goodtablesio-production/issues/287753774/

Discussion:
roll: @amercader 
Please take a look. It addresses https://sentry.io/open-knowledge/goodtablesio-production/issues/287753774/

Patch:
diff --git a/goodtables/presets/table.py b/goodtables/presets/table.py
index 0248096..940a85d 100644
--- a/goodtables/presets/table.py
+++ b/goodtables/presets/table.py
@@ -39,6 +39,10 @@ def table(source, schema=None, **options):
                     warnings.append(
                         'Table schema "%s" has a validation error "%s"' %
                         (schema, str(error).splitlines()[0]))
+            except Exception as error:
+                warnings.append(
+                    'Table Schema "%s" has a loading error "%s"' %
+                    (schema, error))
 
     # Add table
     if not warnings:


Test patch:
diff --git a/tests/presets/test_table.py b/tests/presets/test_table.py
index 1281a86..91fe320 100644
--- a/tests/presets/test_table.py
+++ b/tests/presets/test_table.py
@@ -20,3 +20,10 @@ def test_preset_table_but_got_datapackage_issue_187():
     assert len(warnings) == 1
     assert len(tables) == 0
     assert 'Use "datapackage" preset' in warnings[0]
+
+
+def test_preset_table_invalid_json_issue_196():
+    warnings, tables = presets.table('valid.csv', schema='data/invalid_json.json')
+    assert len(warnings) == 1
+    assert len(tables) == 0
+    assert 'has a loading error' in warnings[0]