瀏覽代碼

Throw Exception on cachefile write error

Josh 9 年之前
父節點
當前提交
f55859ceba
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/Output/QRImage.php

+ 3 - 1
src/Output/QRImage.php

@@ -166,7 +166,9 @@ class QRImage extends QROutputAbstract{
 
 
 		// if saving to file, append the correct headers
 		// if saving to file, append the correct headers
 		if($this->options->cachefile){
 		if($this->options->cachefile){
-			@file_put_contents($this->options->cachefile, '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' . "\n" . $imageData);
+			if(false === @file_put_contents($this->options->cachefile, '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' . "\n" . $imageData)){
+				throw new QRCodeOutputException('Could not write to cache file.');
+			}
 		}
 		}
 
 
 		if((bool)$this->options->base64){
 		if((bool)$this->options->base64){