fluttercandies / flutter_image_compress

flutter image compress
MIT License
632 stars 215 forks source link

Implement toString to CompressError #279

Closed CORDEA closed 5 months ago

CORDEA commented 7 months ago

Hi, thank you for this awesome package!

As a user, I'd like to apply a small improvement to make the error more understandable. CompressError doesn't currently have toString, so unless a logger or similar explicitly reads the #message, the content may be unclear. For example,

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Instance of 'CompressError'
#0      FlutterImageCompressCommon.compressAndGetFile (package:flutter_image_compress_common/flutter_image_compress_common.dart:167:7)
#1      FlutterImageCompress.compressAndGetFile (package:flutter_image_compress/flutter_image_compress.dart:105:22)

After applying this patch.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: CompressError: numberOfRetries can't be null or less than 0
#0      FlutterImageCompressCommon.compressAndGetFile (package:flutter_image_compress_common/flutter_image_compress_common.dart:167:7)
#1      FlutterImageCompress.compressAndGetFile (package:flutter_image_compress/flutter_image_compress.dart:105:22)

Could you please consider if it can be merged?