File tree Expand file tree Collapse file tree 5 files changed +47
-6
lines changed
core/src/main/java/cloud/stackit/sdk/core/exception
authentication/src/main/java/cloud/stackit/sdk/authentication/examples
custom-http-client/src/main/java/cloud/stackit/sdk/customhttpclient/examples
iaas/src/main/java/cloud/stackit/sdk/iaas/examples
resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/examples Expand file tree Collapse file tree 5 files changed +47
-6
lines changed Original file line number Diff line number Diff line change 1+ package cloud .stackit .sdk .core .exception ;
2+
3+ /**
4+ * Exception thrown when SDK operations fail.
5+ * This includes API calls, network issues, and other SDK-related failures.
6+ */
7+ public class SdkException extends RuntimeException {
8+ private static final long serialVersionUID = 1L ;
9+
10+ /**
11+ * Constructs a new SdkException with the specified detail message.
12+ *
13+ * @param message the detail message
14+ */
15+ public SdkException (String message ) {
16+ super (message );
17+ }
18+
19+ /**
20+ * Constructs a new SdkException with the specified detail message and cause.
21+ *
22+ * @param message the detail message
23+ * @param cause the cause of this exception
24+ */
25+ public SdkException (String message , Throwable cause ) {
26+ super (message , cause );
27+ }
28+
29+ /**
30+ * Constructs a new SdkException with the specified cause.
31+ *
32+ * @param cause the cause of this exception
33+ */
34+ public SdkException (Throwable cause ) {
35+ super (cause );
36+ }
37+ }
Original file line number Diff line number Diff line change 22
33import cloud .stackit .sdk .core .config .CoreConfiguration ;
44import cloud .stackit .sdk .core .exception .ApiException ;
5+ import cloud .stackit .sdk .core .exception .SdkException ;
56import cloud .stackit .sdk .resourcemanager .api .ResourceManagerApi ;
67import cloud .stackit .sdk .resourcemanager .model .ListOrganizationsResponse ;
78import java .io .File ;
@@ -34,7 +35,7 @@ public static void main(String[] args) throws IOException {
3435
3536 System .out .println (response .toString ());
3637 } catch (ApiException | IOException e ) {
37- throw new IllegalStateException (e );
38+ throw new SdkException (e );
3839 }
3940
4041 /*
@@ -88,7 +89,7 @@ public static void main(String[] args) throws IOException {
8889
8990 System .out .println (response .toString ());
9091 } catch (ApiException | IOException e ) {
91- throw new IllegalStateException (e );
92+ throw new SdkException (e );
9293 }
9394
9495 /*
@@ -125,7 +126,7 @@ public static void main(String[] args) throws IOException {
125126
126127 System .out .println (response .toString ());
127128 } catch (ApiException | IOException e ) {
128- throw new IllegalStateException (e );
129+ throw new SdkException (e );
129130 }
130131 }
131132}
Original file line number Diff line number Diff line change 33import cloud .stackit .sdk .core .KeyFlowAuthenticator ;
44import cloud .stackit .sdk .core .config .CoreConfiguration ;
55import cloud .stackit .sdk .core .exception .ApiException ;
6+ import cloud .stackit .sdk .core .exception .SdkException ;
67import cloud .stackit .sdk .iaas .api .IaasApi ;
78import cloud .stackit .sdk .iaas .model .*;
89import java .io .IOException ;
@@ -54,7 +55,7 @@ public static void main(String[] args) throws IOException {
5455 System .out .println ("* " + server .getId () + " | " + server .getName ());
5556 }
5657 } catch (ApiException e ) {
57- throw new IllegalStateException (e );
58+ throw new SdkException (e );
5859 }
5960 }
6061}
Original file line number Diff line number Diff line change 11package cloud .stackit .sdk .iaas .examples ;
22
33import cloud .stackit .sdk .core .exception .ApiException ;
4+ import cloud .stackit .sdk .core .exception .SdkException ;
45import cloud .stackit .sdk .iaas .api .IaasApi ;
56import cloud .stackit .sdk .iaas .model .*;
67import java .io .IOException ;
@@ -290,7 +291,7 @@ public static void main(String[] args) throws IOException {
290291 System .out .println ("Deleted network: " + newNetwork .getNetworkId ());
291292
292293 } catch (ApiException | InterruptedException e ) {
293- throw new IllegalStateException (e );
294+ throw new SdkException (e );
294295 }
295296 }
296297}
Original file line number Diff line number Diff line change 11package cloud .stackit .sdk .resourcemanager .examples ;
22
33import cloud .stackit .sdk .core .exception .ApiException ;
4+ import cloud .stackit .sdk .core .exception .SdkException ;
45import cloud .stackit .sdk .resourcemanager .api .ResourceManagerApi ;
56import cloud .stackit .sdk .resourcemanager .model .CreateFolderPayload ;
67import cloud .stackit .sdk .resourcemanager .model .CreateProjectPayload ;
@@ -112,7 +113,7 @@ public static void main(String[] args) throws IOException {
112113 /* delete folder */
113114 resourceManagerApi .deleteFolder (folder .getContainerId (), true );
114115 } catch (ApiException e ) {
115- throw new IllegalStateException (e );
116+ throw new SdkException (e );
116117 }
117118 }
118119}
You can’t perform that action at this time.
0 commit comments