make base class for bencode related errors

This commit is contained in:
mykola2312 2024-10-15 08:37:39 +03:00
parent d67a603039
commit f5ab05acdc
4 changed files with 27 additions and 2 deletions

View file

@ -1,6 +1,6 @@
package com.mykola2312.retracker.bencode.error;
public class BDecodeError extends Exception {
public class BDecodeError extends BError {
private static final long serialVersionUID = 4282658520481186036L;
public byte[] data;

View file

@ -0,0 +1,16 @@
package com.mykola2312.retracker.bencode.error;
/* A base type, all bencode related errors are
* derived from this class for easy try-catching
*/
public class BError extends Exception {
private static final long serialVersionUID = 1626675512183720021L;
public BError(String message) {
super(message);
}
public BError(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -0,0 +1,9 @@
package com.mykola2312.retracker.bencode.error;
public class BErrorNoRoot extends BError {
private static final long serialVersionUID = -7691652539624483490L;
public BErrorNoRoot() {
super("BTree has no root");
}
}

View file

@ -2,7 +2,7 @@ package com.mykola2312.retracker.bencode.error;
import com.mykola2312.retracker.bencode.BValue;
public class BValueError extends Exception {
public class BValueError extends BError {
private static final long serialVersionUID = 6950892783320917930L;
public BValue node;