Commit ad5e7cf
ORC-2430: Improve error message in TypeDescription.withPrecision()
### What changes were proposed in this pull request?
This PR improves the error message in the `TypeDescription.withPrecision(int precision)` method. The previous error message incorrectly stated `precision {value} is out of range 1 .. {scale}` when the scale was greater than precision, which was misleading because it suggested the scale value was the upper bound for precision.
The new error message clearly states: `the scale {scale} must be less than or equal to precision {precision}`, which accurately describes the actual constraint violation.
### Why are the changes needed?
The previous error message was confusing and misleading. When users encountered a case where scale > precision (e.g., precision=5, scale=10), the error message "precision 5 is out of range 1 .. 10" incorrectly suggested that precision must be between 1 and 10, when the real issue was that scale (10) cannot be greater than precision (5).
This improvement enhances the developer experience by providing a clear, accurate error message that directly points to the actual problem, making it easier to diagnose and fix the issue without needing to examine the source code.
### How was this patch tested?
The existing test suite should validate this change. The modification only affects the error message text and does not change the validation logic itself. The same conditions that trigger the exception will continue to do so, but with a clearer message.
To verify the change manually:
1. Create a TypeDescription with decimal type
2. Set scale to a value (e.g., 10)
3. Attempt to set precision to a value less than scale (e.g., 5)
4. Verify the new error message is clear and accurate
### Was this patch authored or co-authored using generative AI tooling?
No
Try to address the issue #2430
Closes #2462 from wgzhao/improve_exception_message.
Lead-authored-by: wgzhao <wgzhao@gmail.com>
Co-authored-by: Steven Zhao <wgzhao@gmail.com>
Signed-off-by: ffacs <ffacs520@gmail.com>1 parent 80b17fd commit ad5e7cf
1 file changed
+8
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
248 | 252 | | |
249 | 253 | | |
250 | 254 | | |
| |||
0 commit comments