Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
samikshya-db committed Nov 6, 2024
1 parent 2470900 commit 1bfd4a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion databricks-sdk-java/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.databricks</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ static void loadFromEnvironmentVariables(DatabricksConfig cfg) throws IllegalAcc
accessor.setValueOnConfig(cfg, env);
}
} catch (DatabricksException e) {
String msg =
String.format("%s auth: %s", cfg.getCredentialsProvider().authType(), e.getMessage());
String msg = String.format("%s auth: %s", cfg.getCredentialsProvider().authType(), e.getMessage());
throw new DatabricksException(msg, e);
}
}
Expand Down Expand Up @@ -89,6 +88,7 @@ static void loadFromConfig(DatabricksConfig cfg) throws IllegalAccessException {

INIConfiguration ini = parseDatabricksCfg(configFile, isDefaultConfig);
if (ini == null) return;

String profile = cfg.getProfile();
boolean hasExplicitProfile = !isNullOrEmpty(profile);
if (!hasExplicitProfile) {
Expand Down Expand Up @@ -166,22 +166,18 @@ static void validate(DatabricksConfig cfg) throws DatabricksException {
}
if (authSet.size() <= 1) return;
String names = String.join(" and ", authSet);
throw new DatabricksException(
String.format("validate: more than one authorization method configured: %s", names));
throw new DatabricksException(String.format("validate: more than one authorization method configured: %s", names));
} catch (IllegalAccessException e) {
throw new DatabricksException("Cannot create default config", e);
}
}

public static DatabricksException makeNicerError(
String message, Exception e, DatabricksConfig cfg) {
public static DatabricksException makeNicerError(String message, Exception e, DatabricksConfig cfg) {
return makeNicerError(message, e, 200, cfg);
}

public static DatabricksException makeNicerError(
String message, Exception e, Integer statusCode, DatabricksConfig cfg) {
boolean isHttpUnauthorizedOrForbidden =
true; // TODO - pass status code with exception, default this to false
public static DatabricksException makeNicerError(String message, Exception e, Integer statusCode, DatabricksConfig cfg) {
boolean isHttpUnauthorizedOrForbidden = true; // TODO - pass status code with exception, default this to false
if (statusCode == 401 || statusCode == 402) isHttpUnauthorizedOrForbidden = true;
String debugString = "";
if (cfg.getEnv() != null) {
Expand Down Expand Up @@ -231,12 +227,12 @@ public static String debugString(DatabricksConfig cfg) {
if (!attrsUsed.isEmpty()) {
buf.add(String.format("Config: %s", String.join(", ", attrsUsed)));
} else {
buf.add(String.format("Config: <empty>"));
buf.add("Config: <empty>");
}
if (!envsUsed.isEmpty()) {
buf.add(String.format("Env: %s", String.join(", ", envsUsed)));
} else {
buf.add(String.format("Env: <none>"));
buf.add("Env: <none>");
}
return String.join(". ", buf);
} catch (IllegalAccessException e) {
Expand Down Expand Up @@ -265,4 +261,4 @@ public static boolean isAnyAuthConfigured(DatabricksConfig cfg) throws IllegalAc
}
return false;
}
}
}

0 comments on commit 1bfd4a3

Please sign in to comment.