forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#1551] improve(server): Optimize the error message (apache#1620)
### What changes were proposed in this pull request? This PR optimize the error message to make it more meaningful to the UI. Previously it outputs the exception class name, which is not meaningful to users. Now change to the actual error message like below: ``` Failed to operate table(s) [ADMINISTRABLE_ROLE_AUTHORIZATIONS] operation [LOAD] under schema [information_schema], reason [Failed to parse create table information_schema.ADMINISTRABLE_ROLE_AUTHORIZATIONS SQL] ``` The reason field is only the error message now. ### Why are the changes needed? To make the error message on UI more meaningful. Fix: apache#1551 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Local verify.
- Loading branch information
Showing
2 changed files
with
64 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
server/src/test/java/com/datastrato/gravitino/server/web/rest/TestExceptionHandlers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.server.web.rest; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class TestExceptionHandlers { | ||
|
||
@Test | ||
public void testGetErrorMsg() { | ||
Exception e1 = new Exception("test1"); | ||
Exception e2 = new Exception("test2", e1); | ||
Exception e3 = new Exception(e1); | ||
Exception e4 = new Exception(); | ||
Exception e5 = new Exception(e2); | ||
Exception e6 = null; | ||
|
||
String msg1 = ExceptionHandlers.BaseExceptionHandler.getErrorMsg(e1); | ||
Assertions.assertEquals("test1", msg1); | ||
|
||
String msg2 = ExceptionHandlers.BaseExceptionHandler.getErrorMsg(e2); | ||
Assertions.assertEquals("test2", msg2); | ||
|
||
String msg3 = ExceptionHandlers.BaseExceptionHandler.getErrorMsg(e3); | ||
Assertions.assertEquals("test1", msg3); | ||
|
||
String msg4 = ExceptionHandlers.BaseExceptionHandler.getErrorMsg(e4); | ||
Assertions.assertEquals("", msg4); | ||
|
||
String msg5 = ExceptionHandlers.BaseExceptionHandler.getErrorMsg(e5); | ||
Assertions.assertEquals("test2", msg5); | ||
|
||
String msg6 = ExceptionHandlers.BaseExceptionHandler.getErrorMsg(e6); | ||
Assertions.assertEquals("", msg6); | ||
} | ||
} |