~sircmpwn/hare-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH rc] interp: catch path:error

Details
Message ID
<20230524205912.21316-1-maxschillinger@web.de>
DKIM signature
pass
Download raw message
Patch: +7 -0
Signed-off-by: Max Schillinger <maxschillinger@web.de>
---
 interp/path.ha | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/interp/path.ha b/interp/path.ha
index afe0caa..c1b5033 100644
--- a/interp/path.ha
+++ b/interp/path.ha
@@ -28,6 +28,13 @@ export fn resolve(cmd: str) (io::file | fs::error) = {
			yield s;
		};

		const buf = match (buf) {
		case path::error =>
			break;
		case let buf: path::buffer =>
			yield buf;
		};

		path::set(&buf, item, cmd)!;
		match (os::open(path::string(&buf))) {
		case fs::error =>
--
2.40.1
Details
Message ID
<CSV7MW4SCTZX.3H9SJ2WSKEH2Z@desktop>
In-Reply-To
<20230524205912.21316-1-maxschillinger@web.de> (view parent)
DKIM signature
pass
Download raw message
On Wed May 24, 2023 at 11:59 PM MSK, Max Schillinger wrote:
> +		const buf = match (buf) {
> +		case path::error =>
> +			break;
> +		case let buf: path::buffer =>
> +			yield buf;
> +		};

It's better to catch that error when initializing the buffer:

@@ -18,7 +18,7 @@ export fn resolve(cmd: str) (io::file | fs::error) = {
                return errors::noentry;
        };
 
-       let buf = path::init();
+       let buf = path::init()!;
        let tok = strings::tokenize(path, ":");
        for (true) {
                const item = match (strings::next_token(&tok)) {
Details
Message ID
<3E024A2D-089D-4C9C-A3CB-B09492FFDEC1@web.de>
In-Reply-To
<CSV7MW4SCTZX.3H9SJ2WSKEH2Z@desktop> (view parent)
DKIM signature
pass
Download raw message
> It's better to catch that error when initializing the buffer:

Fine for me. I'm a Hare beginner and I just wanted to get it work somehow.
Reply to thread Export thread (mbox)