Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 40ba06a

Browse files
authored
Make VCertException error messages more helpful (#23)
By not wrapping all errors in a generic "Unexpected exception" exception. Closes #12.
1 parent 361e641 commit 40ba06a

2 files changed

Lines changed: 1 addition & 47 deletions

File tree

src/main/java/com/venafi/vcert/sdk/VCertClient.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ public void ping() throws VCertException {
103103
connector.ping();
104104
} catch (FeignException e) {
105105
throw VCertException.fromFeignException(e);
106-
} catch (Exception e) {
107-
throw new VCertException("Unexpected exception", e);
108106
}
109107
}
110108

@@ -117,8 +115,6 @@ public void authenticate(Authentication auth) throws VCertException {
117115
connector.authenticate(auth);
118116
} catch (FeignException e) {
119117
throw VCertException.fromFeignException(e);
120-
} catch (Exception e) {
121-
throw new VCertException("Unexpected exception", e);
122118
}
123119
}
124120

@@ -131,8 +127,6 @@ public ZoneConfiguration readZoneConfiguration(String zone) throws VCertExceptio
131127
return connector.readZoneConfiguration(zone);
132128
} catch (FeignException e) {
133129
throw VCertException.fromFeignException(e);
134-
} catch (Exception e) {
135-
throw new VCertException("Unexpected exception", e);
136130
}
137131
}
138132

@@ -146,8 +140,6 @@ public CertificateRequest generateRequest(ZoneConfiguration config, CertificateR
146140
return connector.generateRequest(config, request);
147141
} catch (FeignException e) {
148142
throw VCertException.fromFeignException(e);
149-
} catch (Exception e) {
150-
throw new VCertException("Unexpected exception", e);
151143
}
152144
}
153145

@@ -157,8 +149,6 @@ public String requestCertificate(CertificateRequest request, String zone) throws
157149
return connector.requestCertificate(request, zone);
158150
} catch (FeignException e) {
159151
throw VCertException.fromFeignException(e);
160-
} catch (Exception e) {
161-
throw new VCertException("Unexpected exception", e);
162152
}
163153
}
164154

@@ -172,8 +162,6 @@ public String requestCertificate(CertificateRequest request, ZoneConfiguration z
172162
return connector.requestCertificate(request, zoneConfiguration);
173163
} catch (FeignException e) {
174164
throw VCertException.fromFeignException(e);
175-
} catch (Exception e) {
176-
throw new VCertException("Unexpected exception", e);
177165
}
178166
}
179167

@@ -186,8 +174,6 @@ public PEMCollection retrieveCertificate(CertificateRequest request) throws VCer
186174
return connector.retrieveCertificate(request);
187175
} catch (FeignException e) {
188176
throw VCertException.fromFeignException(e);
189-
} catch (Exception e) {
190-
throw new VCertException("Unexpected exception", e);
191177
}
192178
}
193179

@@ -200,8 +186,6 @@ public void revokeCertificate(RevocationRequest request) throws VCertException {
200186
connector.revokeCertificate(request);
201187
} catch (FeignException e) {
202188
throw VCertException.fromFeignException(e);
203-
} catch (Exception e) {
204-
throw new VCertException("Unexpected exception", e);
205189
}
206190
}
207191

@@ -214,8 +198,6 @@ public String renewCertificate(RenewalRequest request) throws VCertException {
214198
return connector.renewCertificate(request);
215199
} catch (FeignException e) {
216200
throw VCertException.fromFeignException(e);
217-
} catch (Exception e) {
218-
throw new VCertException("Unexpected exception", e);
219201
}
220202
}
221203

@@ -228,8 +210,6 @@ public ImportResponse importCertificate(ImportRequest request) throws VCertExcep
228210
return connector.importCertificate(request);
229211
} catch (FeignException e) {
230212
throw VCertException.fromFeignException(e);
231-
} catch (Exception e) {
232-
throw new VCertException("Unexpected exception", e);
233213
}
234214
}
235215

@@ -242,8 +222,6 @@ public Policy readPolicyConfiguration(String zone) throws VCertException {
242222
return connector.readPolicyConfiguration(zone);
243223
} catch (FeignException e) {
244224
throw VCertException.fromFeignException(e);
245-
} catch (Exception e) {
246-
throw new VCertException("Unexpected exception", e);
247225
}
248226
}
249227
}

src/main/java/com/venafi/vcert/sdk/VCertTknClient.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ public TokenInfo getAccessToken(Authentication auth) throws VCertException{
102102
return connector.getAccessToken(auth);
103103
} catch (FeignException e) {
104104
throw VCertException.fromFeignException(e);
105-
} catch (Exception e) {
106-
throw new VCertException("Unexpected exception", e);
107105
}
108106
}
109107

@@ -113,13 +111,11 @@ public TokenInfo getAccessToken() throws VCertException{
113111
return connector.getAccessToken();
114112
} catch (FeignException e) {
115113
throw VCertException.fromFeignException(e);
116-
} catch (Exception e) {
117-
throw new VCertException("Unexpected exception", e);
118114
}
119115
}
120116

121117
@Override
122-
public TokenInfo refreshAccessToken(String applicationId) throws VCertException{
118+
public TokenInfo refreshAccessToken(String applicationId) throws VCertException {
123119
return connector.refreshAccessToken(applicationId);
124120
}
125121

@@ -137,8 +133,6 @@ public void ping() throws VCertException {
137133
connector.ping();
138134
} catch (FeignException e) {
139135
throw VCertException.fromFeignException(e);
140-
} catch (Exception e) {
141-
throw new VCertException("Unexpected exception", e);
142136
}
143137
}
144138

@@ -151,8 +145,6 @@ public ZoneConfiguration readZoneConfiguration(String zone) throws VCertExceptio
151145
return connector.readZoneConfiguration(zone);
152146
} catch (FeignException e) {
153147
throw VCertException.fromFeignException(e);
154-
} catch (Exception e) {
155-
throw new VCertException("Unexpected exception", e);
156148
}
157149
}
158150

@@ -166,8 +158,6 @@ public CertificateRequest generateRequest(ZoneConfiguration config, CertificateR
166158
return connector.generateRequest(config, request);
167159
} catch (FeignException e) {
168160
throw VCertException.fromFeignException(e);
169-
} catch (Exception e) {
170-
throw new VCertException("Unexpected exception", e);
171161
}
172162
}
173163

@@ -177,8 +167,6 @@ public String requestCertificate(CertificateRequest request, String zone) throws
177167
return connector.requestCertificate(request, zone);
178168
} catch (FeignException e) {
179169
throw VCertException.fromFeignException(e);
180-
} catch (Exception e) {
181-
throw new VCertException("Unexpected exception", e);
182170
}
183171
}
184172

@@ -192,8 +180,6 @@ public String requestCertificate(CertificateRequest request, ZoneConfiguration z
192180
return connector.requestCertificate(request, zoneConfiguration);
193181
} catch (FeignException e) {
194182
throw VCertException.fromFeignException(e);
195-
} catch (Exception e) {
196-
throw new VCertException("Unexpected exception", e);
197183
}
198184
}
199185

@@ -206,8 +192,6 @@ public PEMCollection retrieveCertificate(CertificateRequest request) throws VCer
206192
return connector.retrieveCertificate(request);
207193
} catch (FeignException e) {
208194
throw VCertException.fromFeignException(e);
209-
} catch (Exception e) {
210-
throw new VCertException("Unexpected exception", e);
211195
}
212196
}
213197

@@ -220,8 +204,6 @@ public void revokeCertificate(RevocationRequest request) throws VCertException {
220204
connector.revokeCertificate(request);
221205
} catch (FeignException e) {
222206
throw VCertException.fromFeignException(e);
223-
} catch (Exception e) {
224-
throw new VCertException("Unexpected exception", e);
225207
}
226208
}
227209

@@ -234,8 +216,6 @@ public String renewCertificate(RenewalRequest request) throws VCertException {
234216
return connector.renewCertificate(request);
235217
} catch (FeignException e) {
236218
throw VCertException.fromFeignException(e);
237-
} catch (Exception e) {
238-
throw new VCertException("Unexpected exception", e);
239219
}
240220
}
241221

@@ -248,8 +228,6 @@ public ImportResponse importCertificate(ImportRequest request) throws VCertExcep
248228
return connector.importCertificate(request);
249229
} catch (FeignException e) {
250230
throw VCertException.fromFeignException(e);
251-
} catch (Exception e) {
252-
throw new VCertException("Unexpected exception", e);
253231
}
254232
}
255233

@@ -262,8 +240,6 @@ public Policy readPolicyConfiguration(String zone) throws VCertException {
262240
return connector.readPolicyConfiguration(zone);
263241
} catch (FeignException e) {
264242
throw VCertException.fromFeignException(e);
265-
} catch (Exception e) {
266-
throw new VCertException("Unexpected exception", e);
267243
}
268244
}
269245
}

0 commit comments

Comments
 (0)