Skip to content

Commit

Permalink
rename suffix of error classes from Error to Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
chooyan-eng committed Dec 11, 2024
1 parent 3ce6a7a commit 35a425b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/src/logic/cropper/default_rect_validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ final RectValidator<Image> 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;
};
8 changes: 4 additions & 4 deletions lib/src/logic/cropper/errors.dart
Original file line number Diff line number Diff line change
@@ -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,
});
Expand Down
4 changes: 2 additions & 2 deletions lib/src/logic/parser/errors.dart
Original file line number Diff line number Diff line change
@@ -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);
}
4 changes: 2 additions & 2 deletions lib/src/logic/parser/image_image_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final ImageParser<image.Image> imageImageParser = (data, {inputFormat}) {
late final image.Image? tempImage;
try {
tempImage = _decodeWith(data, format: inputFormat);
} on InvalidInputFormatError {
} on InvalidInputFormatException {
rethrow;
}

Expand Down Expand Up @@ -45,6 +45,6 @@ image.Image? _decodeWith(Uint8List data, {ImageFormat? format}) {
_ => image.decodeImage(data),
};
} on image.ImageException {
throw InvalidInputFormatError(format);
throw InvalidInputFormatException(format);
}
}
6 changes: 3 additions & 3 deletions test/logic/cropper/image_image_cropper_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void main() {
topLeft: Offset(-100, -50),
bottomRight: Offset(200, 150),
),
throwsA(const TypeMatcher<InvalidRectError>()),
throwsA(const TypeMatcher<InvalidRectException>()),
);

expect(
Expand All @@ -68,7 +68,7 @@ void main() {
topLeft: Offset(0, 0),
bottomRight: Offset(-200, -150),
),
throwsA(const TypeMatcher<InvalidRectError>()),
throwsA(const TypeMatcher<InvalidRectException>()),
);
},
);
Expand All @@ -82,7 +82,7 @@ void main() {
topLeft: Offset(200, 50),
bottomRight: Offset(100, 100),
),
throwsA(const TypeMatcher<NegativeSizeError>()),
throwsA(const TypeMatcher<NegativeSizeException>()),
);
},
);
Expand Down
2 changes: 1 addition & 1 deletion test/logic/parser/image_image_parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void main() {
testImage,
inputFormat: ImageFormat.jpeg,
),
throwsA(const TypeMatcher<InvalidInputFormatError>()),
throwsA(const TypeMatcher<InvalidInputFormatException>()),
);
},
);
Expand Down
2 changes: 1 addition & 1 deletion test/widget/helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ class FailureCropper extends ImageCropper {
RectCropper get rectCropper => throw UnimplementedError();

@override
RectValidator get rectValidator => throw Error();
RectValidator get rectValidator => throw Exception();
}

0 comments on commit 35a425b

Please sign in to comment.