Merge pull request #675 from basecamp/command-errors

Show command errors
This commit is contained in:
Jorge Manrubia
2025-07-01 09:56:42 +02:00
committed by GitHub
5 changed files with 42 additions and 3 deletions
@@ -64,6 +64,7 @@ export default class extends Controller {
}
hideError() {
this.#hideOutput()
this.element.classList.remove(this.errorClass)
}
@@ -113,13 +114,15 @@ export default class extends Controller {
const status = response.status
if (status === HttpStatus.UNPROCESSABLE) {
this.#showError()
this.#showError(response)
} else if (status === HttpStatus.CONFLICT) {
await this.#handleConflictResponse(response)
}
}
#showError() {
async #showError(response) {
const message = await response.json()
this.#showOutput(message.error)
this.element.classList.add(this.errorClass)
}