Skip to content

Commit

Permalink
Prefer logger over printStacktrace
Browse files Browse the repository at this point in the history
  • Loading branch information
banterCZ committed Jul 31, 2023
1 parent 8235fea commit 50f98e2
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import lombok.extern.slf4j.Slf4j;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
Expand All @@ -34,8 +35,13 @@
*
* @author Petr Dvorak
*/
@Slf4j
public class QRUtil {

private QRUtil() {
throw new IllegalStateException("Should not be instantiated");
}

/**
* Encode the string data into a QR code of a given size (size = width = height)
* and return the result as "data:" URL.
Expand All @@ -57,7 +63,7 @@ public static String encode(String qrCodeData, int qrCodeSize) {
byte[] bytes = baos.toByteArray();
return "data:image/png;base64," + Base64.getEncoder().encodeToString(bytes);
} catch (WriterException | IOException e) {
e.printStackTrace();
logger.warn("Problem to encode the string data into a QR code", e);
}
return null;
}
Expand Down

0 comments on commit 50f98e2

Please sign in to comment.