Skip to content

Commit

Permalink
fix: change errors not extends Error but implements Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
chooyan-eng committed Dec 11, 2024
1 parent e651777 commit a32bda5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ class _CropSampleState extends State<CropSample> {
switch (result) {
case CropSuccess(:final croppedImage):
_croppedData = croppedImage;
case CropFailure(:final error):
case CropFailure(:final cause):
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Error'),
content:
Text('Failed to crop image: ${error}'),
Text('Failed to crop image: ${cause}'),
actions: [
TextButton(
onPressed: () =>
Expand Down
4 changes: 2 additions & 2 deletions lib/src/logic/cropper/errors.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:ui';

class NegativeSizeError extends Error {
class NegativeSizeError implements Exception {
final Offset topLeft;
final Offset bottomRight;

Expand All @@ -10,7 +10,7 @@ class NegativeSizeError extends Error {
});
}

class InvalidRectError extends Error {
class InvalidRectError implements Exception {
final Offset topLeft;
final Offset bottomRight;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/logic/cropper/image_cropper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class ImageCropper<T> {
CircleCropper<T> get circleCropper;
}

typedef RectValidator<T> = Error? Function(
typedef RectValidator<T> = Exception? Function(
T original, Offset topLeft, Offset bottomRight);
typedef RectCropper<T> = Uint8List Function(
T original, {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/logic/parser/errors.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:crop_your_image/src/logic/format_detector/format.dart';

class InvalidInputFormatError extends Error {
class InvalidInputFormatError implements Exception {
final ImageFormat? inputFormat;

InvalidInputFormatError(this.inputFormat);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/widget/crop_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CropSuccess extends CropResult {
}

class CropFailure extends CropResult {
const CropFailure(this.error, [this.stackTrace]);
final Object error;
const CropFailure(this.cause, [this.stackTrace]);
final Object cause;
final StackTrace? stackTrace;
}
}

0 comments on commit a32bda5

Please sign in to comment.