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
Show 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;
import
com.yanzuoguang.util.contants.ResultConstants
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.vo.ResponseResult
;
/**
...
...
@@ -21,14 +22,14 @@ public class ExceptionHelper {
}
/**
* 不
跑
出异常,记录日常日志
* 不
抛
出异常,记录日常日志
*
* @param cls
* @param ex
* @param from
* @param cls
错误类型
* @param ex
错误
* @param 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 {
* @param local
* @param start
* @param end
* @param all
s
ize
* @param all
S
ize
* @param 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
;
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
;
throw
new
Exception
(
exception
);
}
...
...
@@ -53,7 +54,7 @@ public class ExceptionHelper {
* @param e 异常信息
* @return 返回的数据
*/
public
static
ResponseResult
getError
(
Exception
e
)
{
public
static
ResponseResult
<?>
getError
(
Exception
e
)
{
return
getError
(
e
,
false
);
}
...
...
@@ -63,7 +64,7 @@ public class ExceptionHelper {
* @param e 异常信息
* @return 返回的数据
*/
public
static
ResponseResult
getError
(
Exception
e
,
boolean
isFull
)
{
public
static
ResponseResult
<?>
getError
(
Exception
e
,
boolean
isFull
)
{
if
(
e
instanceof
CodeTargetException
)
{
CodeTargetException
code
=
(
CodeTargetException
)
e
;
return
getError
(
code
.
getCode
(),
code
.
getMessage
(),
code
.
getTarget
(),
true
);
...
...
@@ -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
)
{
return
ResponseResult
.
error
(
code
,
msg
,
target
);
}
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