Skip to content

Commit

Permalink
Merge pull request #874 from guerler/tool_execution_001
Browse files Browse the repository at this point in the history
Use common exceptions in tools
  • Loading branch information
jmchilton committed Oct 10, 2015
2 parents fae21e3 + 45763bf commit 408c82c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion client/galaxy/scripts/mvc/tools/tools-form-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view',
console.debug(response);

// show error
var error_message = ( response && response.error ) || ( response && response.err_msg ) || 'Uncaught error.';
var error_message = ( response && response.err_msg ) || 'Uncaught error.';
if ( self.$el.is(':empty') ) {
self.$el.prepend((new Ui.Message({
message : error_message,
Expand Down
25 changes: 7 additions & 18 deletions lib/galaxy/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2156,12 +2156,9 @@ def to_json(self, trans, kwd={}, job=None, is_workflow=False):
else:
history = trans.get_history()
if history is None:
raise Exception('History unavailable. Please specify a valid history id')
raise exceptions.MessageException( 'History unavailable. Please specify a valid history id' )
except Exception, e:
trans.response.status = 500
error = '[history_id=%s] Failed to retrieve history. %s.' % (history_id, str(e))
log.exception('tools::to_json - %s.' % error)
return { 'error': error }
raise exceptions.MessageException( '[history_id=%s] Failed to retrieve history. %s.' % ( history_id, str( e ) ) )

# load job parameters into incoming
tool_message = ''
Expand All @@ -2172,10 +2169,8 @@ def to_json(self, trans, kwd={}, job=None, is_workflow=False):
self._map_source_to_history( trans, self.inputs, job_params, history )
tool_message = self._compare_tool_version(trans, job)
params_to_incoming( kwd, self.inputs, job_params, trans.app, to_html=False )
except Exception, exception:
trans.response.status = 500
log.error( str( exception ) )
return { 'error': str( exception ) }
except Exception, e:
raise exceptions.MessageException( str( e ) )

# create parameter object
params = galaxy.util.Params( kwd, sanitize=False )
Expand Down Expand Up @@ -2460,10 +2455,6 @@ def sanitize_state(state):
'history_id' : trans.security.encode_id( history.id )
})

# check for errors
if 'error' in tool_message:
return tool_message

# return enriched tool model
return tool_model

Expand Down Expand Up @@ -2553,8 +2544,7 @@ def _compare_tool_version( self, trans, job ):
try:
select_field, tools, tool = self.app.toolbox.get_tool_components( tool_id, tool_version=tool_version, get_loaded_tools_by_lineage=False, set_selected=True )
if tool is None:
trans.response.status = 500
return { 'error': 'This dataset was created by an obsolete tool (%s). Can\'t re-run.' % tool_id }
raise exceptions.MessageException( 'This dataset was created by an obsolete tool (%s). Can\'t re-run.' % tool_id )
if ( self.id != tool_id and self.old_id != tool_id ) or self.version != tool_version:
if self.id == tool_id:
if tool_version is None:
Expand All @@ -2573,9 +2563,8 @@ def _compare_tool_version( self, trans, job ):
else:
message = 'This job was initially run with tool id "%s", version "%s", which is ' % ( tool_id, tool_version )
message += 'currently not available. You can re-run the job with this tool, which is a derivation of the original tool.'
except Exception, error:
trans.response.status = 500
return { 'error': str(error) }
except Exception, e:
raise exceptions.MessageException( str( e ) )
return message

def get_default_history_by_trans( self, trans, create=False ):
Expand Down
2 changes: 1 addition & 1 deletion static/maps/mvc/tools/tools-form-base.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 408c82c

Please sign in to comment.