Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
cfb1cba2
Commit
cfb1cba2
authored
May 20, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将源码打包进jar包
parent
0a5e45a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
ExceptionHelper.java
.../java/com/yanzuoguang/util/exception/ExceptionHelper.java
+12
-11
TestExceptionHelper.java
yzg-util-base/src/test/java/helper/TestExceptionHelper.java
+12
-0
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/exception/ExceptionHelper.java
View file @
cfb1cba2
...
@@ -2,6 +2,7 @@ package com.yanzuoguang.util.exception;
...
@@ -2,6 +2,7 @@ package com.yanzuoguang.util.exception;
import
com.yanzuoguang.util.contants.ResultConstants
;
import
com.yanzuoguang.util.contants.ResultConstants
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
com.yanzuoguang.util.vo.ResponseResult
;
/**
/**
...
@@ -21,14 +22,14 @@ public class ExceptionHelper {
...
@@ -21,14 +22,14 @@ public class ExceptionHelper {
}
}
/**
/**
* 不
跑
出异常,记录日常日志
* 不
抛
出异常,记录日常日志
*
*
* @param cls
* @param cls
错误类型
* @param ex
* @param ex
错误
* @param from
* @param from
错误资源
*/
*/
public
static
void
handleException
(
Class
<?>
cls
,
Throwable
ex
,
Object
from
)
{
public
static
void
handleException
(
Class
<?>
cls
,
Throwable
ex
,
Object
from
)
{
ex
.
printStackTrace
(
);
Log
.
error
(
cls
,
ex
,
StringHelper
.
EMPTY
,
from
);
}
}
/**
/**
...
@@ -37,12 +38,12 @@ public class ExceptionHelper {
...
@@ -37,12 +38,12 @@ public class ExceptionHelper {
* @param local
* @param local
* @param start
* @param start
* @param end
* @param end
* @param all
s
ize
* @param all
S
ize
* @param str
* @param str
* @throws Exception
* @throws Exception
*/
*/
public
static
void
subStringException
(
String
local
,
int
start
,
int
end
,
int
all
s
ize
,
String
str
)
throws
Exception
{
public
static
void
subStringException
(
String
local
,
int
start
,
int
end
,
int
all
S
ize
,
String
str
)
throws
Exception
{
String
exception
=
local
+
"/n"
+
"开始:"
+
start
+
" 结束:"
+
end
+
"总长:"
+
all
s
ize
+
"/n"
+
str
;
String
exception
=
local
+
"/n"
+
"开始:"
+
start
+
" 结束:"
+
end
+
"总长:"
+
all
S
ize
+
"/n"
+
str
;
throw
new
Exception
(
exception
);
throw
new
Exception
(
exception
);
}
}
...
@@ -53,7 +54,7 @@ public class ExceptionHelper {
...
@@ -53,7 +54,7 @@ public class ExceptionHelper {
* @param e 异常信息
* @param e 异常信息
* @return 返回的数据
* @return 返回的数据
*/
*/
public
static
ResponseResult
getError
(
Exception
e
)
{
public
static
ResponseResult
<?>
getError
(
Exception
e
)
{
return
getError
(
e
,
false
);
return
getError
(
e
,
false
);
}
}
...
@@ -63,7 +64,7 @@ public class ExceptionHelper {
...
@@ -63,7 +64,7 @@ public class ExceptionHelper {
* @param e 异常信息
* @param e 异常信息
* @return 返回的数据
* @return 返回的数据
*/
*/
public
static
ResponseResult
getError
(
Exception
e
,
boolean
isFull
)
{
public
static
ResponseResult
<?>
getError
(
Exception
e
,
boolean
isFull
)
{
if
(
e
instanceof
CodeTargetException
)
{
if
(
e
instanceof
CodeTargetException
)
{
CodeTargetException
code
=
(
CodeTargetException
)
e
;
CodeTargetException
code
=
(
CodeTargetException
)
e
;
return
getError
(
code
.
getCode
(),
code
.
getMessage
(),
code
.
getTarget
(),
true
);
return
getError
(
code
.
getCode
(),
code
.
getMessage
(),
code
.
getTarget
(),
true
);
...
@@ -79,7 +80,7 @@ public class ExceptionHelper {
...
@@ -79,7 +80,7 @@ public class ExceptionHelper {
}
}
}
}
private
static
ResponseResult
getError
(
String
code
,
String
msg
,
Object
target
,
boolean
isFull
)
{
private
static
ResponseResult
<?>
getError
(
String
code
,
String
msg
,
Object
target
,
boolean
isFull
)
{
if
(
isFull
)
{
if
(
isFull
)
{
return
ResponseResult
.
error
(
code
,
msg
,
target
);
return
ResponseResult
.
error
(
code
,
msg
,
target
);
}
else
{
}
else
{
...
...
yzg-util-base/src/test/java/helper/TestExceptionHelper.java
0 → 100755
View file @
cfb1cba2
package
helper
;
import
com.yanzuoguang.util.exception.ExceptionHelper
;
import
org.junit.Test
;
public
class
TestExceptionHelper
{
@Test
public
void
testException
()
{
ExceptionHelper
.
handleException
(
TestExceptionHelper
.
class
,
new
Exception
(
"错误"
),
"消息"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment