This repository has been archived by the owner on Oct 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from photoshell/libraw_errors
Libraw errors
- Loading branch information
Showing
4 changed files
with
98 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
class LibrawUnspecifiedError(Exception): | ||
pass | ||
|
||
|
||
class LibrawFileUnsupported(Exception): | ||
pass | ||
|
||
|
||
class LibrawRequestForNonexistentImage(Exception): | ||
pass | ||
|
||
|
||
class LibrawOutOfOrderCall(Exception): | ||
pass | ||
|
||
|
||
class LibrawNoThumbnail(Exception): | ||
pass | ||
|
||
|
||
class LibrawUnsupportedThumbnail(Exception): | ||
pass | ||
|
||
|
||
class LibrawInputClosed(Exception): | ||
pass | ||
|
||
|
||
class LibrawInsufficientMemory(Exception): | ||
pass | ||
|
||
|
||
class LibrawDataError(Exception): | ||
pass | ||
|
||
|
||
class LibrawIOError(Exception): | ||
pass | ||
|
||
|
||
class LibrawCancelledByCallback(Exception): | ||
pass | ||
|
||
|
||
class LibrawBadCrop(Exception): | ||
pass | ||
|
||
|
||
def check_call(exit_code): | ||
if exit_code is not 0: | ||
raise { | ||
-1: LibrawUnspecifiedError, | ||
-2: LibrawFileUnsupported, | ||
-3: LibrawRequestForNonexistentImage, | ||
-4: LibrawOutOfOrderCall, | ||
-5: LibrawNoThumbnail, | ||
-6: LibrawUnsupportedThumbnail, | ||
-7: LibrawInputClosed, | ||
-100007: LibrawInsufficientMemory, | ||
-100008: LibrawDataError, | ||
-100009: LibrawIOError, | ||
-100010: LibrawCancelledByCallback, | ||
-100011: LibrawBadCrop | ||
}[exit_code] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest | ||
|
||
from rawkit.errors import check_call | ||
from rawkit.errors import LibrawUnspecifiedError | ||
|
||
|
||
def test_check_call_success(): | ||
check_call(0) | ||
|
||
|
||
def test_check_call_error(): | ||
with pytest.raises(LibrawUnspecifiedError): | ||
check_call(-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters