Skip to content

Commit 8b690e1

Browse files
committed
narrow the scope of the catch so that fewer errors are masked,
append the original error for user evaluation. this still masks typos in the strfun code, because they're indistinguishable from the strfun not allowed message, and it's impossible to tell, client side, which is which.
1 parent 1ba533e commit 8b690e1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

riak/mapreduce.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,13 @@ def run(self, timeout=None):
277277
try:
278278
result = self._client.mapred(self._inputs, query, timeout)
279279
except RiakError as e:
280-
for phase in self._phases:
281-
if phase._language == 'erlang':
282-
if type(phase._function) is str:
283-
raise RiakError('may have tried erlang strfun when not allowed')
280+
if 'worker_startup_failed' in e.value:
281+
for phase in self._phases:
282+
if phase._language == 'erlang':
283+
if type(phase._function) is str:
284+
raise RiakError('May have tried erlang strfun '
285+
'when not allowed\n'
286+
'original error: ' + e.value)
284287
raise e
285288

286289
# If the last phase is NOT a link phase, then return the result.

riak/tests/test_mapreduce.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def test_erlang_source_map_reduce(self):
101101
[Value]
102102
end.""", {'language': 'erlang'}).run()
103103
except RiakError as e:
104-
strfun_allowed = False
104+
if e.value.startswith('May have tried'):
105+
strfun_allowed = False
105106
if strfun_allowed:
106107
self.assertEqual(result, ['2', '3', '4'])
107108

0 commit comments

Comments
 (0)