Skip to content

Commit

Permalink
error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
fredzqm committed May 10, 2024
1 parent 403cc7c commit bbf2f0d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/dataconnect/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ function errorDetails(err: any, ofType: string): any[] {
const original = err.context?.body?.error || err?.original;
const details: any[] = original?.details;
return details?.filter((d) => d["@type"]?.includes(ofType));
}
}
25 changes: 19 additions & 6 deletions src/dataconnect/schemaMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,29 @@ async function ensureServiceIsConnectedToCloudSql(
}

function displaySchemaChanges(error: IncompatibleSqlSchemaError) {
let message: String = "unknown violation type: " + error.violationType;
switch (error.violationType) {
case "INCOMPATIBLE_SCHEMA":
message = "Your new schema is incompatible with the schema of your CloudSQL database. " +
"The following SQL statements will migrate your database schema to match your new Data Connect schema.\n";
{
const message =
"Your new schema is incompatible with the schema of your CloudSQL database. " +
"The following SQL statements will migrate your database schema to match your new Data Connect schema.\n" +
error.diffs.map(toString).join("\n");
logLabeledWarning("dataconnect", message);
}
break;
case "INACCESSIBLE_SCHEMA":
message = "Cannot access your CloudSQL database to validate schema. " +
"The following SQL statements can setup a new database schema.\n";
{
const message =
"Cannot access your CloudSQL database to validate schema. " +
"The following SQL statements can setup a new database schema.\n" +
error.diffs.map(toString).join("\n");
logLabeledWarning("dataconnect", message);
logLabeledWarning("dataconnect", "Some SQL resources may already exist.");
}
break;
default:
throw new FirebaseError("Unknown schema violation type: " + error.violationType);
}
logLabeledWarning("dataconnect", message + error.diffs.map(toString).join("\n"));
}

function toString(diff: Diff) {
Expand Down

0 comments on commit bbf2f0d

Please sign in to comment.