Minor secret utils error log (#18856)

* fix: pass exception message in SecretUtils.convert

* fix: pass throwable
This commit is contained in:
Teddy 2024-11-29 11:44:44 +01:00 committed by GitHub
parent 04dfbc2257
commit fc01035ce5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -12,6 +12,10 @@ public class InvalidServiceConnectionException extends WebServiceException {
super(Response.Status.BAD_REQUEST, ERROR_TYPE, message); super(Response.Status.BAD_REQUEST, ERROR_TYPE, message);
} }
public InvalidServiceConnectionException(String message, Throwable e) {
super(Response.Status.BAD_REQUEST, ERROR_TYPE, message, e);
}
private InvalidServiceConnectionException(Response.Status status, String message) { private InvalidServiceConnectionException(Response.Status status, String message) {
super(status, ERROR_TYPE, message); super(status, ERROR_TYPE, message);
} }

View File

@ -78,17 +78,20 @@ public final class SecretsUtil {
return ClassConverterFactory.getConverter(clazz).convert(connectionConfig); return ClassConverterFactory.getConverter(clazz).convert(connectionConfig);
} catch (Exception e) { } catch (Exception e) {
// If we have the name we are trying to encrypt a connection // If we have the name we are trying to encrypt a connection
String message = e.getMessage();
if (connectionName != null) { if (connectionName != null) {
throw new InvalidServiceConnectionException( throw new InvalidServiceConnectionException(
String.format( String.format(
"Failed to convert [%s] to type [%s]. Review the connection.", "Failed to convert [%s] to type [%s]. Review the connection.\n%s",
connectionName, connectionType)); connectionName, connectionType, message),
e);
} }
// If we don't have the name, we are decrypting from the db // If we don't have the name, we are decrypting from the db
throw new InvalidServiceConnectionException( throw new InvalidServiceConnectionException(
String.format( String.format(
"Failed to load the connection of type [%s]. Did migrations run properly?", "Failed to load the connection of type [%s]. Did migrations run properly?\n%s",
connectionType)); connectionType, message),
e);
} }
} }
} }