Skip to content
Permalink
Browse files

Merge pull request #500 from mgmax/patch-1

Improve "Camera image is null" error message
  • Loading branch information...
t-oster committed Mar 7, 2019
2 parents 970eda7 + 580d0e4 commit c37034f04c6d6c233f6dc95f55e24a94f0874823
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/com/t_oster/visicut/gui/MainView.java
@@ -2557,7 +2557,13 @@ public void run()
ImageInputStream stream = new MemoryCacheImageInputStream(conn.getInputStream());
BufferedImage back = ImageIO.read(stream);
if (back == null) {
throw new Exception("camera image is null");
if (conn.getHeaderFields().containsKey("Location")) {
// URLConnection does not follow cross-protocol redirects, e.g. from HTTP to HTTPS.
// Then, we'll get stuck here.
// https://stackoverflow.com/questions/1884230/urlconnection-doesnt-follow-redirect
throw new Exception("Did not receive a camera image, but only a HTTP/S redirect. Please use the actual URL instead: " + conn.getHeaderField("Location"));
}
throw new Exception("Cannot read camera image: invalid format or empty file. Please make sure the camera URL returns a valid JPEG or PNG image.");
}
LaserDevice ld = visicutModel1.getSelectedLaserDevice();
if (ld == null || !isCameraActive() || !isPreviewPanelShowBackgroundImage()) {

0 comments on commit c37034f

Please sign in to comment.
You can’t perform that action at this time.