ItsEthra / typst-live

Hot reloading for your typst files
MIT License
85 stars 8 forks source link

Open failing should not cause typst-live to fail #9

Closed apeschar closed 12 months ago

apeschar commented 12 months ago

On Linux, if xdg-open is missing, it breaks typst-live with a "file not found" error on this line.

% typst-live main.typ
[INFO] Server is listening on http://127.0.0.1:5599/
Error: No such file or directory (os error 2)

Location:
    src/main.rs:43:5

https://github.com/ItsEthra/typst-live/blob/e1fbaff9259c94d9bb16c2e8184e1293e69406ab/src/main.rs#L43C12-L43C12

If I figure out how to handle errors in Rust, I'll make my own PR. If I don't get around to it, perhaps you'd like to give it a go.

ItsEthra commented 12 months ago

What would be the other way to open a link without xdg-open?

apeschar commented 12 months ago

Not everyone has their desktop set up so that this works. Or they may run typst-server remotely via SSH and use a SSH tunnel to access the preview (what I was doing). In those cases they'd probably just click the link that is written to the terminal, or manually access the URL somehow.

Point being: absence of tools to open URLs does not imply the user doesn't have another way to open it.

apeschar commented 12 months ago

So in the end: I think we should just log and ignore the error.

ItsEthra commented 12 months ago

Sure, if you want to make a pr that just ignores the error. Just remove ? to avoid propagating the error on the line and discard the result using _ = ... to avoid unhandled result warning.