From 35a425b4d262ab0731442e7e34a8167c7519e1cf Mon Sep 17 00:00:00 2001 From: chooyan-eng Date: Thu, 12 Dec 2024 00:23:11 +0900 Subject: [PATCH] rename suffix of error classes from Error to Exception --- lib/src/logic/cropper/default_rect_validator.dart | 4 ++-- lib/src/logic/cropper/errors.dart | 8 ++++---- lib/src/logic/parser/errors.dart | 4 ++-- lib/src/logic/parser/image_image_parser.dart | 4 ++-- test/logic/cropper/image_image_cropper_test.dart | 6 +++--- test/logic/parser/image_image_parser_test.dart | 2 +- test/widget/helper.dart | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/src/logic/cropper/default_rect_validator.dart b/lib/src/logic/cropper/default_rect_validator.dart index 8c83a69..1d89c7e 100644 --- a/lib/src/logic/cropper/default_rect_validator.dart +++ b/lib/src/logic/cropper/default_rect_validator.dart @@ -16,10 +16,10 @@ final RectValidator defaultRectValidator = topLeft.dy.toInt() > original.height || bottomRight.dx.toInt() > original.width || bottomRight.dy.toInt() > original.height) { - return InvalidRectError(topLeft: topLeft, bottomRight: bottomRight); + return InvalidRectException(topLeft: topLeft, bottomRight: bottomRight); } if (topLeft.dx > bottomRight.dx || topLeft.dy > bottomRight.dy) { - return NegativeSizeError(topLeft: topLeft, bottomRight: bottomRight); + return NegativeSizeException(topLeft: topLeft, bottomRight: bottomRight); } return null; }; diff --git a/lib/src/logic/cropper/errors.dart b/lib/src/logic/cropper/errors.dart index d104d57..f8fb36e 100644 --- a/lib/src/logic/cropper/errors.dart +++ b/lib/src/logic/cropper/errors.dart @@ -1,20 +1,20 @@ import 'dart:ui'; -class NegativeSizeError implements Exception { +class NegativeSizeException implements Exception { final Offset topLeft; final Offset bottomRight; - NegativeSizeError({ + NegativeSizeException({ required this.topLeft, required this.bottomRight, }); } -class InvalidRectError implements Exception { +class InvalidRectException implements Exception { final Offset topLeft; final Offset bottomRight; - InvalidRectError({ + InvalidRectException({ required this.topLeft, required this.bottomRight, }); diff --git a/lib/src/logic/parser/errors.dart b/lib/src/logic/parser/errors.dart index a008781..8db843a 100644 --- a/lib/src/logic/parser/errors.dart +++ b/lib/src/logic/parser/errors.dart @@ -1,7 +1,7 @@ import 'package:crop_your_image/src/logic/format_detector/format.dart'; -class InvalidInputFormatError implements Exception { +class InvalidInputFormatException implements Exception { final ImageFormat? inputFormat; - InvalidInputFormatError(this.inputFormat); + InvalidInputFormatException(this.inputFormat); } diff --git a/lib/src/logic/parser/image_image_parser.dart b/lib/src/logic/parser/image_image_parser.dart index bbf3abf..cf3056d 100644 --- a/lib/src/logic/parser/image_image_parser.dart +++ b/lib/src/logic/parser/image_image_parser.dart @@ -13,7 +13,7 @@ final ImageParser imageImageParser = (data, {inputFormat}) { late final image.Image? tempImage; try { tempImage = _decodeWith(data, format: inputFormat); - } on InvalidInputFormatError { + } on InvalidInputFormatException { rethrow; } @@ -45,6 +45,6 @@ image.Image? _decodeWith(Uint8List data, {ImageFormat? format}) { _ => image.decodeImage(data), }; } on image.ImageException { - throw InvalidInputFormatError(format); + throw InvalidInputFormatException(format); } } diff --git a/test/logic/cropper/image_image_cropper_test.dart b/test/logic/cropper/image_image_cropper_test.dart index e2c87e8..735009c 100644 --- a/test/logic/cropper/image_image_cropper_test.dart +++ b/test/logic/cropper/image_image_cropper_test.dart @@ -59,7 +59,7 @@ void main() { topLeft: Offset(-100, -50), bottomRight: Offset(200, 150), ), - throwsA(const TypeMatcher()), + throwsA(const TypeMatcher()), ); expect( @@ -68,7 +68,7 @@ void main() { topLeft: Offset(0, 0), bottomRight: Offset(-200, -150), ), - throwsA(const TypeMatcher()), + throwsA(const TypeMatcher()), ); }, ); @@ -82,7 +82,7 @@ void main() { topLeft: Offset(200, 50), bottomRight: Offset(100, 100), ), - throwsA(const TypeMatcher()), + throwsA(const TypeMatcher()), ); }, ); diff --git a/test/logic/parser/image_image_parser_test.dart b/test/logic/parser/image_image_parser_test.dart index cd54ffb..45bc68b 100644 --- a/test/logic/parser/image_image_parser_test.dart +++ b/test/logic/parser/image_image_parser_test.dart @@ -52,7 +52,7 @@ void main() { testImage, inputFormat: ImageFormat.jpeg, ), - throwsA(const TypeMatcher()), + throwsA(const TypeMatcher()), ); }, ); diff --git a/test/widget/helper.dart b/test/widget/helper.dart index d2c4391..c9e6cda 100644 --- a/test/widget/helper.dart +++ b/test/widget/helper.dart @@ -20,5 +20,5 @@ class FailureCropper extends ImageCropper { RectCropper get rectCropper => throw UnimplementedError(); @override - RectValidator get rectValidator => throw Error(); + RectValidator get rectValidator => throw Exception(); }