TurboJPEG: Improve error handling

- Provide a new C API function and TJException method that allows
  calling programs to query the severity of a compression/decompression/
  transform error.
- Provide a new flag that instructs the library to immediately stop
  compressing/decompressing/transforming if a warning is encountered.

Fixes #151
This commit is contained in:
DRC
2017-06-27 10:54:21 -05:00
parent 42e1e2d886
commit d4092f6b4d
21 changed files with 531 additions and 49 deletions

View File

@@ -1,5 +1,6 @@
/*
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
* Copyright (C)2017 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -46,8 +47,26 @@ public class TJException extends IOException {
super(message);
}
public TJException(String message, int code) {
super(message);
if (errorCode >= 0 && errorCode < TJ.NUMERR)
errorCode = code;
}
public TJException(Throwable cause) {
super(cause);
}
/**
* Returns a code (one of {@link TJ TJ.ERR_*}) indicating the severity of the
* last error.
*
* @return a code (one of {@link TJ TJ.ERR_*}) indicating the severity of the
* last error.
*/
public int getErrorCode() {
return errorCode;
}
private int errorCode = TJ.ERR_FATAL;
}