Skip to content

Commit

Permalink
Explicitly handle EPIPE #8
Browse files Browse the repository at this point in the history
  • Loading branch information
vknabel committed Oct 23, 2021
1 parent 7c6792f commit 4f5c47b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.11.4
10.22.1
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.1.3

- Explicitly handle EPIPE errors #8 - [@vknabel](https://github.com/vknabel/)

# 1.1.2

[CVE-2021-28789](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-28789): Fixes vulnerability which allowed malicous workspaces to execute code when opened by providing. Now the vulnerable configs cannot be overrided in workspaces anymore: `apple-swift-format.path`. Reported by [@Ry0taK](https://github.com/Ry0taK).
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "git",
"url": "https://github.com/vknabel/vscode-apple-swift-format"
},
"version": "1.1.2",
"version": "1.1.3",
"license": "MIT",
"author": {
"name": "Valentin Knabel",
Expand Down Expand Up @@ -88,9 +88,9 @@
},
"devDependencies": {
"@types/node": "^10.12.10",
"prettier": "^1.15.2",
"typescript": "^3.0.1",
"@types/vscode": "^1.26.0"
"@types/vscode": "^1.26.0",
"prettier": "^2.4.1",
"typescript": "^4.0.0"
},
"dependencies": {}
}
21 changes: 15 additions & 6 deletions src/UserInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,32 @@ export async function handleFormatError(
Current.config.configureSwiftFormatPath();
break;
}
} else if (error.code === "EPIPE") {
await Current.editor.showErrorMessage(
`apple/swift-format was closed. ${error.stderr || ""}`
);
} else if (error.status === 70) {
await Current.editor.showErrorMessage(
`apple/swift-format failed. ${error.stderr || ""}`
);
} else if (error.status === 1 && stdinIncompatibleSwiftSyntaxErrorRegex.test(error.message)) {
} else if (
error.status === 1 &&
stdinIncompatibleSwiftSyntaxErrorRegex.test(error.message)
) {
const selection = await Current.editor.showWarningMessage(
`apple/swift-format does not fit your Swift version. Do you need to update it?`,
'How?'
)
"How?"
);
if (selection == "How?") {
await Current.editor.openURL('https://github.com/vknabel/vscode-apple-swift-format#appleswift-format-for-vs-code')
await Current.editor.openURL(
"https://github.com/vknabel/vscode-apple-swift-format#appleswift-format-for-vs-code"
);
}
} else if (error.status === 1 && stdinErrorRegex.test(error.message)) {
const execArray = stdinErrorRegex.exec(error.message)!
const execArray = stdinErrorRegex.exec(error.message)!;
Current.editor.showWarningMessage(
`${path.basename(document.fileName)}${execArray[1]}`
)
);
} else {
const unknownErrorSelection = await Current.editor.showErrorMessage(
`An unknown error occurred. ${error.message || ""}`,
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@


"@types/node@^10.12.10":
version "10.17.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.5.tgz#c1920150f7b90708a7d0f3add12a06bc9123c055"
integrity sha512-RElZIr/7JreF1eY6oD5RF3kpmdcreuQPjg5ri4oQ5g9sq7YWU8HkfB3eH8GwAwxf5OaCh0VPi7r4N/yoTGelrA==
version "10.17.60"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b"
integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==

"@types/vscode@^1.26.0":
version "1.43.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.43.0.tgz#22276e60034c693b33117f1068ffaac0e89522db"
integrity sha512-kIaR9qzd80rJOxePKpCB/mdy00mz8Apt2QA5Y6rdrKFn13QNFNeP3Hzmsf37Bwh/3cS7QjtAeGSK7wSqAU0sYQ==
version "1.61.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.61.0.tgz#c54335b6f84c19c69b1435b17cc0ce3b2cecfeec"
integrity sha512-9k5Nwq45hkRwdfCFY+eKXeQQSbPoA114mF7U/4uJXRBJeGIO7MuJdhF1PnaDN+lllL9iKGQtd6FFXShBXMNaFg==

prettier@^1.15.2:
version "1.19.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
prettier@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c"
integrity sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==

typescript@^3.0.1:
version "3.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb"
integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==
typescript@^4.0.0:
version "4.4.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c"
integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==

0 comments on commit 4f5c47b

Please sign in to comment.