Skip to content

suda#read throws uncaught exception when opening suda:///not-existing.txt #18

Open
@doronbehar

Description

Hey,

I noticed that if I launch nvim suda:///not-existing.txt and /not-existing.txt doesn't exist, I get an exception:

Error detected while processing function suda#BufReadCmd[5]..suda#read:
line   28:
E605: Exception not caught:

Here's where this happens, for reference:

https://github.com/lambdalisue/suda.vim/blob/b867074b30f623ccb81a0bb8d1b74a6d0fafd160/autoload/suda.vim#L70-L77

cat fails because the file doesn't exist. Technically this error is harmless because if the file doesn't exist the buffer should be empty anyway. Perhaps this 'bug' shouldn't even be fixed?

We could ignore any errors but that won't be reliable if e.g the password was incorrect. As I'm thinking about it, this part of suda should be implemented with extreme care because if no error is thrown, a user might think he opened an empty file, add something according to some manual, save it (without errors) and end up with a totally different file with all the previous content lost.

According to my tests, even a wrong password ends up with an empty buffer and the same exception error is printed. Maybe suda should clearly state to the user what command failed and that the buffer's contents don't correspond to the real contents? Unless of course the file doesn't exist.. Anyway, I wonder what is your opinion on the subject.

Thanks.

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions