-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new ZstdIOException when replacing IOException
So that we don't break backward compatibility - ZstdIOException is subclass of the IOException so signatures don't have to be changed.
- Loading branch information
Showing
7 changed files
with
103 additions
and
56 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
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,47 @@ | ||
package com.github.luben.zstd; | ||
|
||
import java.io.IOException; | ||
|
||
public class ZstdIOException extends IOException { | ||
private long code; | ||
|
||
/** | ||
* Construct a ZstdException from the result of a Zstd library call. | ||
* | ||
* The error code and message are automatically looked up using | ||
* Zstd.getErrorCode and Zstd.getErrorName. | ||
* | ||
* @param result the return value of a Zstd library call | ||
*/ | ||
public ZstdIOException(long result) { | ||
this(Zstd.getErrorCode(result), Zstd.getErrorName(result)); | ||
} | ||
|
||
/** | ||
* Construct a ZstdException with a manually-specified error code and message. | ||
* | ||
* No transformation of either the code or message is done. It is advised | ||
* that one of the Zstd.err*() is used to obtain a stable error code. | ||
* | ||
* @param code a Zstd error code | ||
* @param message the exception's message | ||
*/ | ||
public ZstdIOException(long code, String message) { | ||
super(message); | ||
this.code = code; | ||
} | ||
|
||
/** | ||
* Get the Zstd error code that caused the exception. | ||
* | ||
* This will likely correspond to one of the Zstd.err*() methods, but the | ||
* Zstd library may return error codes that are not yet stable. In such | ||
* cases, this method will return the code reported by Zstd, but it will | ||
* not correspond to any of the Zstd.err*() methods. | ||
* | ||
* @return a Zstd error code | ||
*/ | ||
public long getErrorCode() { | ||
return 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
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
Oops, something went wrong.