-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update secret error messages across the UI (#25085)
relates to #24550 more updates to the various secret error messages after some API changes - [x] Manual QA for all new/changed functionality
- Loading branch information
1 parent
f2a15bc
commit 631af6b
Showing
7 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { getErrorReason } from "interfaces/errors"; | ||
|
||
/** | ||
* helper function to generate error message for secret variables based | ||
* on the error reason. | ||
*/ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export const generateSecretErrMsg = (err: unknown) => { | ||
const reason = getErrorReason(err); | ||
|
||
let errorType = ""; | ||
if (getErrorReason(err, { nameEquals: "install script" })) { | ||
errorType = "install script"; | ||
} else if (getErrorReason(err, { nameEquals: "post-install script" })) { | ||
errorType = "post-install script"; | ||
} else if (getErrorReason(err, { nameEquals: "uninstall script" })) { | ||
errorType = "uninstall script"; | ||
} else if (getErrorReason(err, { nameEquals: "profile" })) { | ||
errorType = "profile"; | ||
} | ||
|
||
if (errorType === "profile") { | ||
return reason | ||
.split(":")[1] | ||
.replace(/Secret variables?/i, "Variable") | ||
.replace("missing from database", "doesn't exist."); | ||
} | ||
|
||
// all other specific error types | ||
if (errorType) { | ||
return reason | ||
.replace(/Secret variables?/i, `Variable used in ${errorType} `) | ||
.replace("missing from database", "doesn't exist."); | ||
} | ||
|
||
// no spcial error type. return generic secret error message | ||
return reason | ||
.replace(/Secret variables?/i, "Variable") | ||
.replace("missing from database", "doesn't exist."); | ||
}; |