Project

General

Profile

exception handling

Added by Adonai Canez almost 11 years ago

Hi,

I want to handle exceptions when the image file is locked, but try and catch is not working. What is wrong?

try{
image->writeMetadata();
}
catch(Exiv2::Error& e){
std::cout << "Error" << std::endl;
}
catch(std::exception &e){
std::cout << "Error" << std::endl;
}

terminate called after throwing an instance of 'Exiv2::BasicError<char>'
what(): C:/Users/Adonai S. Canez/Desktop/20101211 - Pedal até Pedro Osório/DSCN6656.JPG: Failed to open file (w+b): Permission denied (errno = 13)


Replies (3)

RE: exception handling - Added by Mikayel Egibyan over 5 years ago

Has this been resolved? I am still getting this error for some multi frame tiff files.

Mikayel

RE: exception handling - Added by Robin Mills over 5 years ago

I don't think try/catch can save the situation here. I think you will have to use a signal handler. This is discussed here: http://dev.exiv2.org/issues/1164#note-6

You'll see that, the user agreed with my judgement that Signal handlers are process wide and should be used by applications and not libraries.

Here's a discussion on Stack Overflow about the difference between exception handlers (a C++ feature) and signal handlers (a process feature). http://stackoverflow.com/questions/1717991/throwing-an-exception-from-within-a-signal-handler

    (1-3/3)