-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display an edit configuration button on deployment failure message fo…
…r invalid toml
- Loading branch information
Showing
9 changed files
with
328 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (C) 2024 by Posit Software, PBC. | ||
|
||
import { window } from "vscode"; | ||
import { openFileInEditor } from "src/commands"; | ||
import { | ||
isErrInvalidConfigFile, | ||
isErrInvalidTOMLFile, | ||
isErrTomlUnknownError, | ||
isErrTOMLValidationError, | ||
isErrUnknownTOMLKey, | ||
} from "src/utils/errorTypes"; | ||
import { getSummaryStringFromError } from "src/utils/errors"; | ||
|
||
// Handler for deployment failures, but intended to only handled the | ||
// errors reported back from the deployment API request. Most deployment | ||
// failures will be returned and handled by the event stream processing | ||
// once the agent has kicked off the anonymous go function which walks through | ||
// the deployment process. | ||
export const showImmediateDeploymentFailureMessage = async (error: unknown) => { | ||
if ( | ||
isErrTomlUnknownError(error) || | ||
isErrUnknownTOMLKey(error) || | ||
isErrInvalidTOMLFile(error) || | ||
isErrTOMLValidationError(error) || | ||
isErrInvalidConfigFile(error) | ||
) { | ||
const editButtonStr = "Edit Configuration"; | ||
const options = [editButtonStr]; | ||
const summary = getSummaryStringFromError("homeView, deploy", error); | ||
const selection = await window.showErrorMessage( | ||
`Failed to deploy. ${summary}`, | ||
...options, | ||
); | ||
// will not support line and column either. | ||
if (selection === editButtonStr) { | ||
if ( | ||
isErrTOMLValidationError(error) || | ||
isErrTomlUnknownError(error) || | ||
isErrInvalidConfigFile(error) | ||
) { | ||
openFileInEditor(error.response.data.details.filename); | ||
return; | ||
} | ||
openFileInEditor(error.response.data.details.filename, { | ||
selection: { | ||
start: { | ||
line: error.response.data.details.line - 1, | ||
character: error.response.data.details.column - 1, | ||
}, | ||
}, | ||
}); | ||
} | ||
return; | ||
} | ||
|
||
// Default handling for deployment failures we are not handling in a particular way | ||
const summary = getSummaryStringFromError("homeView, deploy", error); | ||
return window.showErrorMessage(`Failed to deploy . ${summary}`); | ||
}; |
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
Oops, something went wrong.