forked from eclipse-ee4j/tyrus
-
Notifications
You must be signed in to change notification settings - Fork 1
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 eclipse-ee4j#881 from jansupol/20.m1
Merge 2.0.x into 2.1.x
- Loading branch information
Showing
22 changed files
with
472 additions
and
117 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
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
44 changes: 44 additions & 0 deletions
44
client/src/main/java/org/glassfish/tyrus/client/exception/DeploymentHandshakeException.java
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,44 @@ | ||
/* | ||
* Copyright (c) 2023, 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.tyrus.client.exception; | ||
|
||
import org.glassfish.tyrus.core.HandshakeException; | ||
|
||
import jakarta.websocket.DeploymentException; | ||
|
||
/** | ||
* The {@link DeploymentException} wrapping the {@link HandshakeException} and makes the HTTP status code accessible directly. | ||
*/ | ||
public class DeploymentHandshakeException extends DeploymentException { | ||
|
||
public DeploymentHandshakeException(String message) { | ||
super(message); | ||
} | ||
|
||
public DeploymentHandshakeException(String message, HandshakeException cause) { | ||
super(message, cause); | ||
} | ||
|
||
/** | ||
* Get the error code. | ||
* | ||
* @return the error code. | ||
*/ | ||
public int getHttpStatusCode() { | ||
return ((HandshakeException) getCause()).getHttpStatusCode(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
client/src/main/java/org/glassfish/tyrus/client/exception/Exceptions.java
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,43 @@ | ||
/* | ||
* Copyright (c) 2023, 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.tyrus.client.exception; | ||
|
||
import org.glassfish.tyrus.core.HandshakeException; | ||
|
||
import jakarta.websocket.DeploymentException; | ||
|
||
/** | ||
* Converts the exceptions into more specific ones. | ||
*/ | ||
public class Exceptions { | ||
|
||
/** | ||
* Get the Deployment Exception, or return the exception if of the type. | ||
* @param message The Exception message | ||
* @param cause The Cause Exception | ||
* @return a Deployment exception. | ||
*/ | ||
public static DeploymentException deploymentException(String message, Throwable cause) { | ||
if (DeploymentException.class.isInstance(cause)) { | ||
return (DeploymentException) cause; | ||
} else if (HandshakeException.class.isInstance(cause)) { | ||
return new DeploymentHandshakeException(message, (HandshakeException) cause); | ||
} else { | ||
return new DeploymentException(message, cause); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
client/src/main/java/org/glassfish/tyrus/client/exception/package-info.java
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,20 @@ | ||
/* | ||
* Copyright (c) 2023, 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
/** | ||
* Common Client Exceptions | ||
*/ | ||
package org.glassfish.tyrus.client.exception; |
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.