# Logging !?Entry errors and continuing

**URL:** <https://ziggit.dev/t/logging-entry-errors-and-continuing/16653>\
**Category:** Help\
**Tags:** language, error-handling\
**Created:** [July 11, 2026, 12:31pm UTC](https://ziggit.dev/t/logging-entry-errors-and-continuing/16653 "2026-07-11T12:31:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![QuaternionWake](https://ziggit.dev/user_avatar/ziggit.dev/quaternionwake/32/6355_2.png) [@QuaternionWake](https://ziggit.dev/u/QuaternionWake)\
**Post date:** [July 11, 2026, 12:31pm UTC](https://ziggit.dev/t/logging-entry-errors-and-continuing/16653/1 "2026-07-11T12:31:07Z")

</div>

I’ve been writing a small program (that I’m hoping to showcase soon!) that needs to walk a directory tree to do its job.

The basic code I want to write is as follows:

```zig
while (walker.next()) |ok| {
    const entry = ok orelse break; // walker is finished
    // do stuff with entry...
} else |err| {
    switch (err) {
        // handle errors, mostly by just printing them
    }
    continue;
}

```

But it doesn’t compile, because the `continue` in the final line is not considered to be in a loop!

I’ve tried handling errors inside the condition, but that lead me to multiple layers of while loops to avoid the terminate-on-error behavior and really seemed excessively large and rather unreadable for what it was trying to achieve.

A second-best sort of solution I thought up was to somehow invert the optional and error (turning `Error!?Entry` into `?Error!Entry`) writing the loop like so:

```zig
while (invert(walker.next())) |err| {
    const entry = err catch |e| switch (e) {
        // handle errors, mostly by just printing them
    }
    // do stuff with entry...
}

```

But although the `invert()` function does seem like it will work, at this point I started getting the feeling that I’m on the wrong track altogether here and am missing a much simpler solution. Is there a better way, or is this the way to go about it?

---

<div class="post-metadata">

**Author:** ![vulpesx](https://ziggit.dev/user_avatar/ziggit.dev/vulpesx/32/3989_2.png) [@vulpesx](https://ziggit.dev/u/vulpesx)\
**Post date:** [July 11, 2026, 12:57pm UTC](https://ziggit.dev/t/logging-entry-errors-and-continuing/16653/2 "2026-07-11T12:57:14Z")

</div>

```zig
while (true) {
    // not sure if () are needed...
    const entry = (walker.next() catch |e| switch (e) {
        //...
    }) orelse break;
    // or perhaps split into 2 consts
}

```

---

<div class="post-metadata">

**Author:** ![QuaternionWake](https://ziggit.dev/user_avatar/ziggit.dev/quaternionwake/32/6355_2.png) [@QuaternionWake](https://ziggit.dev/u/QuaternionWake)\
**Post date:** [July 11, 2026, 1:27pm UTC](https://ziggit.dev/t/logging-entry-errors-and-continuing/16653/3 "2026-07-11T13:27:54Z")

</div>

Simple as that, huh?  
It works great, thanks a lot!
