Skip to content

Commit

Permalink
Replace hardcoded error values with enums
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Oct 29, 2023
1 parent ebd4987 commit da30a49
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/littlefs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def mkdir(self, path: str) -> int:
try:
return lfs.mkdir(self.fs, path)
except errors.LittleFSError as e:
if e.code == -17:
if e.code == LittleFSError.Error.LFS_ERR_EXIST:
msg = "[LittleFSError {:d}] Cannot create a file when that file already exists: '{:s}'.".format(
e.code, path
)
Expand Down Expand Up @@ -264,7 +264,7 @@ def remove(self, path: str) -> int:
try:
return lfs.remove(self.fs, path)
except errors.LittleFSError as e:
if e.code == -2:
if e.code == LittleFSError.Error.LFS_ERR_NOENT:
msg = "[LittleFSError {:d}] No such file or directory: '{:s}'.".format(
e.code, path
)
Expand All @@ -287,7 +287,7 @@ def removedirs(self, name):
break
self.remove('/'.join(parts))
except errors.LittleFSError as e:
if e.code == -39:
if e.code == LittleFSError.Error.LFS_ERR_NOTEMPTY:
break
raise e
parts.pop()
Expand Down

0 comments on commit da30a49

Please sign in to comment.