Skip to content

verror should handle %w  #208

Open
Open
@cosnicolaou

Description

@cosnicolaou

verror.Errorf does not currently understand %w and leads to ugly output when it's used, see the example code below outputs:

err: t: cause: %!w(*errors.errorString=&{an error})
cause: an error
package main

import (
        "errors"
        "fmt"

        "v.io/v23/verror"
)

func main() {
        var (
                cause = errors.New("an error")
                err   = verror.ErrInternal.Errorf(nil, "cause: %w", cause)
        )
        // The printing does not handle the "%w" nicely...
        fmt.Printf("err: %v\n", err)

        // ... even though the wrapping is done correctly.
        fmt.Printf("cause: %v\n", errors.Unwrap(err))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions