Skip to content

Commit

Permalink
Merge pull request ome#532 from will-moore/handle_image_loading_errors
Browse files Browse the repository at this point in the history
Handle image loading errors
  • Loading branch information
will-moore authored Dec 14, 2023
2 parents cc3b592 + 504a5d6 commit e9b01f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 10 additions & 6 deletions omero_figure/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,19 @@ def img_data_json(request, image_id, conn=None, **kwargs):

if units_support:
# Add extra parameters with units data
if 'pixel_size' not in rv:
rv['pixel_size'] = {}
# NB ['pixel_size']['x'] will have size in MICROMETER
px = image.getPrimaryPixels().getPhysicalSizeX()
rv['pixel_size']['valueX'] = px.getValue()
rv['pixel_size']['symbolX'] = px.getSymbol()
rv['pixel_size']['unitX'] = str(px.getUnit())
if px is not None:
rv['pixel_size']['valueX'] = px.getValue()
rv['pixel_size']['symbolX'] = px.getSymbol()
rv['pixel_size']['unitX'] = str(px.getUnit())
py = image.getPrimaryPixels().getPhysicalSizeY()
rv['pixel_size']['valueY'] = py.getValue()
rv['pixel_size']['symbolY'] = py.getSymbol()
rv['pixel_size']['unitY'] = str(py.getUnit())
if py is not None:
rv['pixel_size']['valueY'] = py.getValue()
rv['pixel_size']['symbolY'] = py.getSymbol()
rv['pixel_size']['unitY'] = str(py.getUnit())
pz = image.getPrimaryPixels().getPhysicalSizeZ()
if pz is not None:
rv['pixel_size']['valueZ'] = pz.getValue()
Expand Down
6 changes: 6 additions & 0 deletions src/js/models/figure_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,12 @@
dataType: dataType,
// work with the response
success: function( data ) {
if (data.Exception || data.ConcurrencyException) {
// If something went wrong, show error and don't add to figure
message = data.Exception || "ConcurrencyException"
alert(`Image loading from ${imgDataUrl} included an Error: ${message}`);
return;
}

self.set('loading_count', self.get('loading_count') - 1);

Expand Down

0 comments on commit e9b01f7

Please sign in to comment.