Skip to content

Commit 704a86b

Browse files
committed
feat: add EPERM error handling to getErrorMessage
Signed-off-by: leocavalcante <leo@cavalcante.dev>
1 parent 26131ad commit 704a86b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/paths.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export function getErrorMessage(error, file, targetPath) {
6464
switch (code) {
6565
case "EACCES":
6666
return `Permission denied. Check write permissions for ${dirname(targetPath)}`
67+
case "EPERM":
68+
return "Operation not permitted. The file may be in use or locked"
6769
case "ENOSPC":
6870
return "Disk full. Free up space and try again"
6971
case "ENOENT":

tests/paths.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ describe("paths.mjs exports", () => {
111111
)
112112
})
113113

114+
it("should return operation not permitted message for EPERM error", () => {
115+
const error = Object.assign(new Error("EPERM"), { code: "EPERM" })
116+
const result = getErrorMessage(error, testFile, testTargetPath)
117+
expect(result).toBe("Operation not permitted. The file may be in use or locked")
118+
})
119+
114120
it("should return disk full message for ENOSPC error", () => {
115121
const error = Object.assign(new Error("ENOSPC"), { code: "ENOSPC" })
116122
const result = getErrorMessage(error, testFile, testTargetPath)

0 commit comments

Comments
 (0)