Commit aff8222f authored by gongzuquan's avatar gongzuquan

异常信息优化

parent 1c3d04f9
......@@ -13,9 +13,57 @@ public class YzgError {
private static YzgErrorData error = new YzgErrorData("999.");
private static void init() {
error.add("000","%s");
error.add("001", "该页面未绑定表");
error.add("002", "类%s未发现表结构");
error.add("003", "类%未发现SQL语句%s");
error.add("003", "类%s未发现SQL语句%s");
error.add("004", "泛型继承检测错误");
error.add("005","视频文件不存在");
error.add("006","对象%s不能复制");
error.add("007","整形转换成字节的PCD码必须小于100");
error.add("008","不能识别文件类型%s");
error.add("009","文件类型不为图片、音频、视频");
error.add("010","文件%s已存在文件,不能创建目录");
error.add("011","创建文件夹失败");
error.add("012","文件删除失败");
error.add("013","变量名%s不支持");
error.add("014","正则表达式错误");
error.add("015","length params is error, must be greater than 0, this params is [%s]");
error.add("016","random code, essential data is empty.");
error.add("017","生成时间搓 MD5 ID 时,时间不能为空");
error.add("018","压缩时文件夹对象不能为空。");
error.add("019","[%s]不是一个文件夹,或者不存在。");
error.add("020","删除文件失败");
error.add("021","文件%s不存在");
error.add("022","没有抛出异常");
error.add("023","监视错误");
error.add("024","导出时请传入配置信息");
error.add("025","不能处理非本条件的字段");
error.add("026","代码片段%s:%s:%s为单数");
error.add("027","SqlCondItem不支持输入参数,必须带代码片段");
error.add("028","需要格式化的字符串不支持");
error.add("029","表%s主键值为空时不能更新");
error.add("030","修改失败,请确认是否被其他人修改,版本号传入是否正确");
error.add("031","统计类型[%s]不支持");
error.add("032","SQL语句%s不存在纬度%s");
error.add("033","表中未包含MD5字段");
error.add("034","Excel已初始化");
error.add("035","保存失败");
error.add("036","保存路径%s失败");
error.add("037","%s失败,该数据可能已被修改");
error.add("038","size请在0~1之间");
error.add("039","视频转码压缩时文件不存在:%s");
error.add("040","audioBitRateZip请在0~1之间");
error.add("041","videoSizeZip请在0~1之间");
error.add("042","videoBitRateZip请在0~1之间");
error.add("043","你需要格式化的字符串格式为空");
error.add("044","不能获取文件Mime类型%s");
error.add("045","下载失败");
error.add("046","创建对象%s出错");
error.add("047","不能识别模板");
error.add("048","获取视频所缩类图失败:%s");
}
private static void initTemp() {
......
package com.yanzuoguang.util.base;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.exception.ExceptionHelper;
import com.yanzuoguang.util.helper.StringHelper;
......@@ -253,7 +254,7 @@ public class ObjectHelper {
writeWithFromClass(to, from);
return (T) to;
} catch (Exception e) {
throw new RuntimeException("对象" + cls.getName() + "不能复制", e);
throw YzgError.getRuntimeException(e,"006",cls.getName());
}
}
......
package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.YzgError;
/**
* 通信格式转换
......@@ -542,7 +543,7 @@ public class ByteHelper {
*/
public static byte toBCD(int from) {
if (from >= BCD_MAX_FLAG) {
throw new RuntimeException("整形转换成字节的PCD码必须小于100");
throw YzgError.getRuntimeException("007");
}
byte bt = (byte) ((from / BYTE_TEN_UNIT * BYTE_HEX_UNIT) + from % BYTE_TEN_UNIT);
return bt;
......
package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.YzgError;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
......@@ -35,7 +37,7 @@ public class FileHelper {
String contentType = Files.probeContentType(path);
return contentType;
} catch (Exception ex) {
throw new RuntimeException("不能获取文件Mime类型" + filePath, ex);
throw YzgError.getRuntimeException(ex,"044",filePath);
}
}
......@@ -49,12 +51,12 @@ public class FileHelper {
public static int getMediaType(String file) {
String mimeType = FileHelper.getMimeType(file);
if (mimeType == null) {
throw new RuntimeException("不能识别文件类型" + file);
throw YzgError.getRuntimeException("008",file);
}
int type = getMediaTypeByMime(mimeType);
// System.out.println(mimeType);
if (type == FILE_TYPE_NONE) {
throw new RuntimeException("文件类型不为图片、音频、视频");
throw YzgError.getRuntimeException("009");
}
return type;
}
......@@ -100,7 +102,7 @@ public class FileHelper {
if (file.isDirectory()) {
return StringHelper.EMPTY;
} else {
throw new RuntimeException("文件" + file.getName() + "已存在文件,不能创建目录");
throw YzgError.getRuntimeException("010",file.getName());
}
}
file.mkdirs();
......@@ -183,11 +185,11 @@ public class FileHelper {
if (parentFile != null) {
if (!parentFile.exists()) {
if (!parentFile.mkdirs()) {
throw new RuntimeException("创建文件夹失败");
throw YzgError.getRuntimeException("011");
}
}
if (!parentFile.exists()) {
throw new RuntimeException("创建文件夹失败");
throw YzgError.getRuntimeException("011");
}
}
// 文件不存在则创建
......@@ -218,11 +220,11 @@ public class FileHelper {
// 删除文件
if (file.exists()) {
if (!file.delete()) {
throw new RuntimeException("文件删除失败");
throw YzgError.getRuntimeException("012");
}
}
if (file.exists()) {
throw new RuntimeException("文件删除失败");
throw YzgError.getRuntimeException("012");
}
writeFileAppend(file, content, encoding);
} catch (RuntimeException e) {
......
package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.YzgError;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -47,7 +49,7 @@ public class FormulaHelper {
public static final int getExcelIndex(String columnName) {
columnName = columnName.toLowerCase();
if (!columnName.matches("^[a-z]+$")) {
throw new RuntimeException("变量名" + columnName + "不支持");
throw YzgError.getRuntimeException("013",columnName);
}
// 从名称转换列序号
int formulaColumnIndex = 0;
......@@ -208,7 +210,7 @@ public class FormulaHelper {
Pattern p = Pattern.compile(regex);
Matcher matcher = p.matcher(formula);
if (!matcher.find()) {
throw new RuntimeException("正则表达式错误");
throw YzgError.getRuntimeException("014");
}
return matcher;
}
......
package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.contants.SystemContants;
import java.util.Random;
......@@ -63,7 +64,7 @@ public final class RandomHelper {
*/
public static String generateRandomCodeSix(int len) {
if (len < 1) {
throw new RuntimeException("length params is error, must be greater than 0, this params is [" + len + "]");
throw YzgError.getRuntimeException("015",len);
}
StringBuffer sb = new StringBuffer();
......@@ -82,11 +83,11 @@ public final class RandomHelper {
*/
public static String generateRandomCode(String charset, int len) {
if (null == charset || "".equals(charset)) {
throw new RuntimeException("random code, essential data is empty.");
throw YzgError.getRuntimeException("016");
}
if (len < 1) {
throw new RuntimeException("length params is error, must be greater than 0, this params is [" + len + "]");
throw YzgError.getRuntimeException("015",len);
}
StringBuffer sb = new StringBuffer();
......
package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.thread.ThreadHelper;
/**
......@@ -50,7 +51,7 @@ public class RunHelper {
}
}
if (ex != null) {
throw new RuntimeException(tag + ex.getMessage(), ex);
throw YzgError.getRuntimeException(ex,"000",tag + ex.getMessage());
}
}
}
package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.exception.ExceptionHelper;
......@@ -959,7 +960,7 @@ public class StringHelper {
*/
public static String getNewMD5Id(Date date, Object... froms) {
if (date == null) {
throw new RuntimeException("生成时间搓 MD5 ID 时,时间不能为空");
throw YzgError.getRuntimeException("017");
}
String tag = getNewIdTag(date.getTime());
String id = md51(getId(froms));
......
......@@ -2,6 +2,8 @@ package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.YzgError;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
......@@ -38,10 +40,10 @@ public class ZipHelper {
*/
public static void zipDirectory(File dirFile, File zipFile, boolean isDir) throws IOException {
if (dirFile == null) {
throw new RuntimeException("压缩时文件夹对象不能为空。");
throw YzgError.getRuntimeException("018");
}
if (!dirFile.isDirectory()) {
throw new RuntimeException("[" + dirFile.getName() + "]不是一个文件夹,或者不存在。");
throw YzgError.getRuntimeException("019",dirFile.getName());
}
if (zipFile == null) {
zipFile = new File(dirFile.getAbsolutePath() + ".zip");
......@@ -157,7 +159,7 @@ public class ZipHelper {
if (flag) {
tempFile.renameTo(zipTo);
} else {
throw new RuntimeException("删除文件失败");
throw YzgError.getRuntimeException("020");
}
}
}
......@@ -215,7 +217,7 @@ public class ZipHelper {
*/
private static void zipFile(String sourcePath, File file, ZipOutputStream zipOutStream, BufferedOutputStream bufferOutStream) throws IOException {
if (!file.exists()) {
throw new RuntimeException("文件" + file.getAbsolutePath() + "不存在");
throw YzgError.getRuntimeException("021",file.getAbsolutePath());
}
// 创建压缩文件实体
ZipEntry entry = new ZipEntry(sourcePath + file.getName());
......
package com.yanzuoguang.util.thread;
import com.yanzuoguang.util.YzgError;
/**
* 根据指定的线程数量, 执行多个Runnable对象
*
......@@ -27,7 +29,7 @@ public class RunnableList extends AbstractThreadList<Runnable> {
} catch (RuntimeException ex) {
throw ex;
} catch (Exception ex) {
throw new RuntimeException(ex.getMessage(), ex);
throw YzgError.getRuntimeException("000",ex.getMessage());
}
}
}
package com.yanzuoguang.util.thread;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.helper.StringHelper;
import java.util.Date;
......@@ -157,7 +158,7 @@ public class RunnableListAutoItem implements Comparable<RunnableListAutoItem> {
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
} else {
throw new RuntimeException(ex.getMessage(), ex);
throw YzgError.getRuntimeException("000",ex.getMessage());
}
}
......
package helper;
import base.DemoVo;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.helper.*;
import com.yanzuoguang.util.vo.ResponseResult;
import helper.vo.ResponseDataMainResult;
......@@ -35,7 +36,7 @@ public class TestSfzUtil {
File f = new File("src/test/java/helper/" + from);
if (!f.exists()) {
System.out.println(f.getAbsoluteFile());
throw new RuntimeException("视频文件不存在");
throw YzgError.getRuntimeException("005");
}
return f.getAbsolutePath();
}
......
package helper;
import base.DemoVo;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.helper.TypeHelper;
import com.yanzuoguang.util.vo.ResponseResult;
import helper.vo.ResponseDataMainResult;
......@@ -23,7 +24,7 @@ public class TestTypeHelper {
TypeHelper.printSuperClass(returnType);
boolean isSub = TypeHelper.isSubType(returnType, ResponseResult.class);
if (!isSub) {
throw new RuntimeException("泛型继承检测错误");
throw YzgError.getRuntimeException("004");
}
}
}
package thread;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.thread.RunnableListAuto;
import com.yanzuoguang.util.thread.ThreadHelper;
......@@ -27,7 +28,7 @@ public class TestRunnableListAuto {
public void test() {
try {
runTest(true);
throw new RuntimeException("没有抛出异常");
throw YzgError.getRuntimeException("022");
} catch (Exception ex) {
// Log.error(TestRunnableListAuto.class, ex);
}
......
package com.yanzuoguang.cloud.aop;
import com.yanzuoguang.util.YzgError;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
......@@ -19,7 +20,7 @@ public class WebAspectUtil {
public static HttpServletRequest getRequest() {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (attributes == null) {
throw new RuntimeException("监视错误");
throw YzgError.getRuntimeException("023");
}
return attributes.getRequest();
}
......
......@@ -3,6 +3,7 @@ package com.yanzuoguang.cloud.excel;
import com.yanzuoguang.cloud.helper.HttpFileHelper;
import com.yanzuoguang.excel.*;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.helper.FileHelper;
import com.yanzuoguang.util.helper.JsonHelper;
import com.yanzuoguang.util.helper.StringHelper;
......@@ -103,7 +104,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
public static <T extends Object, M extends Object> void export(ExportBase<T> req, HttpServletResponse response, ExcelDao<T, M> excelDao) {
ExportData config = req.getConfig();
if (config == null) {
throw new RuntimeException("导出时请传入配置信息");
throw YzgError.getRuntimeException("024");
}
if (StringHelper.isEmpty(config.getServerPath())) {
config.setServerPath("/home/cache/");
......@@ -136,7 +137,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
} catch (IOException e) {
isDown = true;
e.printStackTrace();
throw new RuntimeException("下载失败", e);
throw YzgError.getRuntimeException(e,"045");
} finally {
if (isDown) {
// 删除生成的临时文件
......
......@@ -3,6 +3,7 @@ package com.yanzuoguang.dao.cond;
import com.yanzuoguang.dao.DaoConst;
import com.yanzuoguang.dao.impl.SqlData;
import com.yanzuoguang.dao.impl.SqlDataField;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.helper.StringHelper;
......@@ -82,7 +83,7 @@ public abstract class SqlCondBase<T extends SqlCondBase> implements SqlCond<T> {
@Override
public String getSql(String sql, SqlData sqlData, SqlDataField sqlDataField, Object model, Map<String, List<String>> codeMap) {
if (sqlDataField.getCond() != this) {
throw new RuntimeException("不能处理非本条件的字段");
throw YzgError.getRuntimeException("025");
}
if (debugRunnable != null) {
// 用于断点调试的支持
......@@ -101,7 +102,7 @@ public abstract class SqlCondBase<T extends SqlCondBase> implements SqlCond<T> {
String fieldName = this.fields.isEmpty() ? StringHelper.EMPTY : this.fields.get(0);
// 判断代码片段是否合法
if (sqlDataField.getCodes().size() % 2 == 1) {
throw new RuntimeException("代码片段" + this.getClass().getSimpleName() + ":" + sqlData.getName() + ":" + fieldName + "为单数");
throw YzgError.getRuntimeException("026",this.getClass().getSimpleName(),sqlData.getName(),fieldName);
}
// 处理代码片段
for (int i = 0; i < sqlDataField.getCodes().size(); i = i + DaoConst.CODE_UNIT) {
......
......@@ -3,6 +3,7 @@ package com.yanzuoguang.dao.cond;
import com.yanzuoguang.dao.DaoConst;
import com.yanzuoguang.dao.impl.SqlData;
import com.yanzuoguang.dao.impl.SqlDataField;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.helper.ArrayHelper;
import com.yanzuoguang.util.helper.StringHelper;
......@@ -60,7 +61,7 @@ public class SqlCondItem extends SqlCondBase<SqlCondItem> {
@Override
public String getSql(String sql, SqlData sqlData, SqlDataField sqlDataField, Object model, Map<String, List<String>> codeMap) {
if (sqlDataField.getCond() != this) {
throw new RuntimeException("不能处理非本条件的字段");
throw YzgError.getRuntimeException("025");
}
if (debugRunnable != null) {
// 用于断点调试的支持
......@@ -69,13 +70,13 @@ public class SqlCondItem extends SqlCondBase<SqlCondItem> {
int condType = getCondType(model, sqlDataField);
switch (condType) {
case COND_TYPE_CONST_ONLY_PARA: {
throw new RuntimeException("SqlCondItem不支持输入参数,必须带代码片段");
throw YzgError.getRuntimeException("027");
}
case COND_TYPE_CODE_COND: {
String fieldName = this.fields.isEmpty() ? StringHelper.EMPTY : this.fields.get(0);
// 判断代码片段是否合法
if (sqlDataField.getCodes().size() % 2 == 1) {
throw new RuntimeException("代码片段" + this.getClass().getSimpleName() + ":" + sqlData.getName() + ":" + fieldName + "为单数");
throw YzgError.getRuntimeException("026",this.getClass().getSimpleName(),sqlData.getName(),fieldName);
}
Object value = ObjectHelper.get(model, fieldName);
List list = ArrayHelper.getList(value);
......
......@@ -4,6 +4,7 @@ import com.yanzuoguang.dao.BaseDao;
import com.yanzuoguang.dao.DaoConst;
import com.yanzuoguang.dao.QueryPara;
import com.yanzuoguang.db.DbExecute;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.DateHelper;
......@@ -50,7 +51,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*/
protected String getKey() {
if (this.table == null) {
throw new RuntimeException("类" + this.getClass().getName() + "未发现表结构");
throw YzgError.getRuntimeException("002");
}
return this.table.getTable().getKeyName();
}
......@@ -170,13 +171,13 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
public String update(Object model) {
String keyString = this.getKeyString(model);
if (StringHelper.isEmpty(keyString)) {
throw new RuntimeException("表" + this.table.getTable().getName() + "主键值为空时不能更新");
throw YzgError.getRuntimeException("029",this.table.getTable().getName());
}
this.check(DaoConst.OPERATOR_TYPE_UPDATE, keyString, model);
SqlData sqlData = this.getSql(DaoConst.UPDATE);
int ret = updateSql(sqlData, model);
if (ret == 0) {
throw new RuntimeException("修改失败,请确认是否被其他人修改,版本号传入是否正确");
throw YzgError.getRuntimeException("030");
}
String retVal = ret > 0 ? keyString : "";
return retVal;
......@@ -865,7 +866,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
try {
from = cls.newInstance();
} catch (Exception ex) {
throw new RuntimeException("创建对象" + cls.getName() + "出错", ex);
throw YzgError.getRuntimeException(ex,"046",cls.getName());
}
ObjectHelper.writeWithFrom(from, request);
return this.create(from);
......
......@@ -792,7 +792,7 @@ public abstract class BaseDaoSql {
sb.append("AVG");
break;
default:
throw new RuntimeException("统计类型[" + from.getGroupType() + "]不支持");
throw YzgError.getRuntimeException("031",from.getGroupType());
}
sb.append("( CASE WHEN ");
sb.append(from.getCaseField());
......
package com.yanzuoguang.dao.impl;
import com.yanzuoguang.dao.DaoConst;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.cache.MemoryCache;
import com.yanzuoguang.util.helper.StringHelper;
......@@ -169,7 +170,7 @@ public class TableSqlCache {
for (String item : tableWhereField.getFields()) {
String name = item.toLowerCase();
if (!sqlFieldHas.containsKey(name)) {
throw new RuntimeException("SQL语句" + item + "不存在纬度" + item);
throw YzgError.getRuntimeException("032",item,item);
}
sqlFieldWhere.put(name, true);
}
......@@ -195,7 +196,7 @@ public class TableSqlCache {
} else if (!StringHelper.isEmpty(this.table.getMD5KeyName())) {
addString(map, "{Key}", this.table.getMD5KeyName());
} else {
throw new RuntimeException("表中未包含MD5字段");
throw YzgError.getRuntimeException("033");
}
String lowerKey = this.table.getKeyName().toLowerCase();
......
package com.yanzuoguang.excel;
import com.yanzuoguang.db.impl.DbRow;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.helper.CheckerHelper;
import com.yanzuoguang.util.helper.FileHelper;
import com.yanzuoguang.util.helper.StringHelper;
......@@ -167,7 +168,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
*/
protected void initExcel(TableHead head) {
if (this.workbook != null) {
throw new RuntimeException("Excel已初始化");
throw YzgError.getRuntimeException("034");
}
// 创建合并对象数据检测
mergerGroup = new HashMap<>();
......@@ -393,21 +394,21 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
out.flush();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("保存失败");
throw YzgError.getRuntimeException("035");
} finally {
out.close();
}
// 判断临时文件是否存在
File file = new File(fileNameTemp);
if (!file.exists()) {
throw new RuntimeException("保存路径" + this.getFileName() + "失败");
throw YzgError.getRuntimeException("036",this.getFileName());
}
// 重命名成正式文件
String fileName = this.getFileName();
file.renameTo(new File(fileName));
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("保存失败");
throw YzgError.getRuntimeException("035");
}
return this;
}
......@@ -428,7 +429,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
File file = new File(this.getFileName());
if (file.exists()) {
if (!file.delete()) {
throw new RuntimeException("文件删除失败");
throw YzgError.getRuntimeException("012");
}
}
return this;
......
......@@ -2,6 +2,7 @@ package com.yanzuoguang.service.impl;
import com.yanzuoguang.dao.BaseDao;
import com.yanzuoguang.service.BaseService;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.helper.StringHelper;
import java.util.ArrayList;
......@@ -185,7 +186,7 @@ public abstract class BaseServiceImpl<T> implements BaseService<T> {
*/
private void check(String opTag, String serviceTag, Object id) {
if (StringHelper.isEmpty(id)) {
throw new RuntimeException(opTag + serviceTag + "失败,该数据可能已被修改");
throw YzgError.getRuntimeException("037",opTag + serviceTag);
}
}
......
......@@ -221,7 +221,7 @@ public class MediaHelperExtend extends ImageHelper {
String format, String codeC,
float size, int bitRate) throws EncoderException {
if (size > 1) {
throw new RuntimeException("size请在0~1之间");
throw YzgError.getRuntimeException("038");
}
File source = new File(fromFile);
File target = new File(toFile);
......
package helper;
import com.yanzuoguang.util.MediaHelperExtend;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.helper.FileHelper;
import com.yanzuoguang.util.thread.RunnableListAuto;
import it.sauronsoftware.jave.Encoder;
......@@ -75,7 +76,7 @@ public class TestMediaHelper {
File f = new File("src/test/java/helper/" + file);
if (!f.exists()) {
System.out.println(f.getAbsoluteFile());
throw new RuntimeException("视频文件不存在");
throw YzgError.getRuntimeException("005");
}
return f.getAbsolutePath();
}
......
......@@ -140,7 +140,7 @@ public class MediaHelper extends ImageHelper {
// 源文件判断
File source = new File(fromFile);
if (!source.exists()) {
throw new RuntimeException("视频转码压缩时文件不存在:" + fromFile);
throw YzgError.getRuntimeException("039",fromFile);
}
File target = new File(toFile);
if (!target.getParentFile().exists()) {
......@@ -163,7 +163,7 @@ public class MediaHelper extends ImageHelper {
String suffix = toFile.substring(toFile.lastIndexOf(".") + 1);
getGrabberFFmpegImage(fromFile, toFile, suffix, FRAME_INDEX);
} catch (IOException ex) {
throw new RuntimeException("获取视频所缩类图失败:" + ex.getMessage(), ex);
throw YzgError.getRuntimeException(ex,"048",ex.getMessage());
}
}
......
......@@ -249,13 +249,13 @@ public class MediaParameter extends BaseVo {
this.videoSizeZip = StringHelper.getFirst(this.videoSizeZip, 1f);
this.videoBitRateZip = StringHelper.getFirst(this.videoBitRateZip, 1f);
if (audioBitRateZip > 1) {
throw new RuntimeException("audioBitRateZip请在0~1之间");
throw YzgError.getRuntimeException("040");
}
if (videoSizeZip > 1) {
throw new RuntimeException("videoSizeZip请在0~1之间");
throw YzgError.getRuntimeException("041");
}
if (videoBitRateZip > 1) {
throw new RuntimeException("videoBitRateZip请在0~1之间");
throw YzgError.getRuntimeException("042");
}
}
......
......@@ -19,7 +19,7 @@ public class TestMediaHelper {
File f = new File("src/test/java/helper/" + file);
if (!f.exists()) {
System.out.println(f.getAbsoluteFile());
throw new RuntimeException("视频文件不存在");
throw YzgError.getRuntimeException("005");
}
return f.getAbsolutePath();
}
......
......@@ -67,7 +67,7 @@ public class PrinterHelper {
try {
pager = JsonHelper.deserialize(from.getPager(), PrinterPagerData.class);
} catch (Exception ex) {
throw new RuntimeException("不能识别模板", ex);
throw YzgError.getRuntimeException(ex,"047");
}
// 设置偏移量
pager.setMarginTop(pager.getMarginTop() + top);
......
package com.yanzuoguang.util.printer.format;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.helper.StringHelper;
import java.util.HashMap;
......@@ -52,7 +53,7 @@ public class FormatCenter {
private String format(String command, String formatValue) {
this.initDefault();
if (StringHelper.isEmpty(command)) {
throw new RuntimeException("你需要格式化的字符串格式为空");
throw YzgError.getRuntimeException("043");
}
String[] commands = command.split(":");
String name = commands[0];
......@@ -62,7 +63,7 @@ public class FormatCenter {
}
FormatHandle formatHandle = cache.get(name);
if (formatHandle == null) {
throw new RuntimeException("需要格式化的字符串不支持");
throw YzgError.getRuntimeException("028");
}
return formatHandle.getFormat(name, format, formatValue);
}
......
......@@ -72,7 +72,7 @@ public class TestPrinterHelper {
File f = new File("src/test/java/helper/" + from);
if (!f.exists()) {
System.out.println(f.getAbsoluteFile());
throw new RuntimeException("视频文件不存在");
throw YzgError.getRuntimeException("005");
}
return f.getAbsolutePath();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment