Skip to content

Commit fa16b55

Browse files
committed
Deprecate ErrorType
This change deprecates ErrorType as the same constants are already declared in ErrorFrameFlyweight and there is hierarchy of exceptions with one exception per error code. Signed-off-by: Rossen Stoyanchev <[email protected]>
1 parent c686d5e commit fa16b55

15 files changed

+34
-29
lines changed

rsocket-core/src/main/java/io/rsocket/RSocketErrorException.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public class RSocketErrorException extends RuntimeException {
2828

2929
private static final long serialVersionUID = -1628781753426267554L;
3030

31+
private static final int MIN_ERROR_CODE = 0x00000001;
32+
33+
private static final int MAX_ERROR_CODE = 0xFFFFFFFE;
34+
3135
private final int errorCode;
3236

3337
/**
@@ -50,9 +54,7 @@ public RSocketErrorException(int errorCode, String message) {
5054
public RSocketErrorException(int errorCode, String message, @Nullable Throwable cause) {
5155
super(message, cause);
5256
this.errorCode = errorCode;
53-
54-
// Avoid dependency on frame package
55-
if (errorCode > 0xFFFFFFFE && errorCode < 0x00000001) {
57+
if (errorCode > MAX_ERROR_CODE && errorCode < MIN_ERROR_CODE) {
5658
throw new IllegalArgumentException(
5759
"Allowed errorCode value should be in range [0x00000001-0xFFFFFFFE]", this);
5860
}

rsocket-core/src/main/java/io/rsocket/exceptions/ApplicationErrorException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
/**
@@ -45,6 +45,6 @@ public ApplicationErrorException(String message) {
4545
* @param cause the cause of this exception
4646
*/
4747
public ApplicationErrorException(String message, @Nullable Throwable cause) {
48-
super(ErrorType.APPLICATION_ERROR, message, cause);
48+
super(ErrorFrameFlyweight.APPLICATION_ERROR, message, cause);
4949
}
5050
}

rsocket-core/src/main/java/io/rsocket/exceptions/CanceledException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
/**
@@ -46,6 +46,6 @@ public CanceledException(String message) {
4646
* @param cause the cause of this exception
4747
*/
4848
public CanceledException(String message, @Nullable Throwable cause) {
49-
super(ErrorType.CANCELED, message, cause);
49+
super(ErrorFrameFlyweight.CANCELED, message, cause);
5050
}
5151
}

rsocket-core/src/main/java/io/rsocket/exceptions/ConnectionCloseException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
/**
@@ -46,6 +46,6 @@ public ConnectionCloseException(String message) {
4646
* @param cause the cause of this exception
4747
*/
4848
public ConnectionCloseException(String message, @Nullable Throwable cause) {
49-
super(ErrorType.CONNECTION_CLOSE, message, cause);
49+
super(ErrorFrameFlyweight.CONNECTION_CLOSE, message, cause);
5050
}
5151
}

rsocket-core/src/main/java/io/rsocket/exceptions/ConnectionErrorException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
/**
@@ -46,6 +46,6 @@ public ConnectionErrorException(String message) {
4646
* @param cause the cause of this exception
4747
*/
4848
public ConnectionErrorException(String message, @Nullable Throwable cause) {
49-
super(ErrorType.CONNECTION_ERROR, message, cause);
49+
super(ErrorFrameFlyweight.CONNECTION_ERROR, message, cause);
5050
}
5151
}

rsocket-core/src/main/java/io/rsocket/exceptions/CustomRSocketException.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
public class CustomRSocketException extends RSocketException {
@@ -43,8 +43,8 @@ public CustomRSocketException(int errorCode, String message) {
4343
*/
4444
public CustomRSocketException(int errorCode, String message, @Nullable Throwable cause) {
4545
super(errorCode, message, cause);
46-
if (errorCode > ErrorType.MAX_USER_ALLOWED_ERROR_CODE
47-
&& errorCode < ErrorType.MIN_USER_ALLOWED_ERROR_CODE) {
46+
if (errorCode > ErrorFrameFlyweight.MAX_USER_ALLOWED_ERROR_CODE
47+
&& errorCode < ErrorFrameFlyweight.MIN_USER_ALLOWED_ERROR_CODE) {
4848
throw new IllegalArgumentException(
4949
"Allowed errorCode value should be in range [0x00000301-0xFFFFFFFE]", this);
5050
}

rsocket-core/src/main/java/io/rsocket/exceptions/InvalidException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
/**
@@ -45,6 +45,6 @@ public InvalidException(String message) {
4545
* @param cause the cause of this exception
4646
*/
4747
public InvalidException(String message, @Nullable Throwable cause) {
48-
super(ErrorType.INVALID, message, cause);
48+
super(ErrorFrameFlyweight.INVALID, message, cause);
4949
}
5050
}

rsocket-core/src/main/java/io/rsocket/exceptions/InvalidSetupException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
/**
@@ -46,6 +46,6 @@ public InvalidSetupException(String message) {
4646
* @param cause the cause of this exception
4747
*/
4848
public InvalidSetupException(String message, @Nullable Throwable cause) {
49-
super(ErrorType.INVALID_SETUP, message, cause);
49+
super(ErrorFrameFlyweight.INVALID_SETUP, message, cause);
5050
}
5151
}

rsocket-core/src/main/java/io/rsocket/exceptions/RSocketException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.rsocket.exceptions;
1818

1919
import io.rsocket.RSocketErrorException;
20+
import io.rsocket.frame.ErrorFrameFlyweight;
2021
import reactor.util.annotation.Nullable;
2122

2223
/**
@@ -46,7 +47,7 @@ public RSocketException(String message) {
4647
* @param cause the cause of this exception
4748
*/
4849
public RSocketException(String message, @Nullable Throwable cause) {
49-
super(0x00000201, message, cause);
50+
super(ErrorFrameFlyweight.APPLICATION_ERROR, message, cause);
5051
}
5152

5253
/**

rsocket-core/src/main/java/io/rsocket/exceptions/RejectedException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
/**
@@ -47,6 +47,6 @@ public RejectedException(String message) {
4747
* @param cause the cause of this exception
4848
*/
4949
public RejectedException(String message, @Nullable Throwable cause) {
50-
super(ErrorType.REJECTED, message, cause);
50+
super(ErrorFrameFlyweight.REJECTED, message, cause);
5151
}
5252
}

rsocket-core/src/main/java/io/rsocket/exceptions/RejectedResumeException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
/**
@@ -45,6 +45,6 @@ public RejectedResumeException(String message) {
4545
* @param cause the cause of this exception
4646
*/
4747
public RejectedResumeException(String message, @Nullable Throwable cause) {
48-
super(ErrorType.REJECTED_RESUME, message, cause);
48+
super(ErrorFrameFlyweight.REJECTED_RESUME, message, cause);
4949
}
5050
}

rsocket-core/src/main/java/io/rsocket/exceptions/RejectedSetupException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
/**
@@ -45,6 +45,6 @@ public RejectedSetupException(String message) {
4545
* @param cause the cause of this exception
4646
*/
4747
public RejectedSetupException(String message, @Nullable Throwable cause) {
48-
super(ErrorType.REJECTED_SETUP, message, cause);
48+
super(ErrorFrameFlyweight.REJECTED_SETUP, message, cause);
4949
}
5050
}

rsocket-core/src/main/java/io/rsocket/exceptions/SetupException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
/** The root of the setup exception hierarchy. */
@@ -44,7 +44,7 @@ public SetupException(String message) {
4444
*/
4545
@Deprecated
4646
public SetupException(String message, @Nullable Throwable cause) {
47-
this(ErrorType.INVALID_SETUP, message, cause);
47+
this(ErrorFrameFlyweight.INVALID_SETUP, message, cause);
4848
}
4949

5050
/**

rsocket-core/src/main/java/io/rsocket/exceptions/UnsupportedSetupException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.rsocket.exceptions;
1818

19-
import io.rsocket.frame.ErrorType;
19+
import io.rsocket.frame.ErrorFrameFlyweight;
2020
import javax.annotation.Nullable;
2121

2222
/**
@@ -45,6 +45,6 @@ public UnsupportedSetupException(String message) {
4545
* @param cause the cause of this exception
4646
*/
4747
public UnsupportedSetupException(String message, @Nullable Throwable cause) {
48-
super(ErrorType.UNSUPPORTED_SETUP, message, cause);
48+
super(ErrorFrameFlyweight.UNSUPPORTED_SETUP, message, cause);
4949
}
5050
}

rsocket-core/src/main/java/io/rsocket/frame/ErrorType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*
66
* @see <a href="https://github.com/rsocket/rsocket/blob/master/Protocol.md#error-codes">Error
77
* Codes</a>
8+
* @deprecated please use constants in {@link ErrorFrameFlyweight}.
89
*/
10+
@Deprecated
911
public final class ErrorType {
1012

1113
/**

0 commit comments

Comments
 (0)