zipper icon indicating copy to clipboard operation
zipper copied to clipboard

Remove exception

Open Lecrapouille opened this issue 4 years ago • 2 comments

Confusing API: either return false or throw exception. We should use a single poison :) When returning false could be nice to have a sterror/errno method to return a human readble error message.

Lecrapouille avatar Feb 12 '21 21:02 Lecrapouille

If we want to do it more C++, then C. We can model it after the std::filesystem calls. Where you can give in an std::error_code that holds this information.

Unzipper zipfile("example.zip");
std::error_code err;
if(!zipfile.extract("someFolder", err) || err != 0){
     //Something went wrong
     std::cout << "Error extracting, got Zipper error msg: " << err.message() << "\n";
}

This allows us to just have multiple call, and keep the old API, and not break it.

This I belive I can start to implement that, but I am not familliar enough with the implementation of the C style getLastError .. etc

Togtja avatar May 10 '21 11:05 Togtja

Good point on using std::error :)

Lecrapouille avatar May 10 '21 18:05 Lecrapouille

Closing since implemented on Unzipper for the v2.x.y branch. In gestation: the Zipper classe

Lecrapouille avatar Sep 10 '22 21:09 Lecrapouille