Skip to content

Conversation

@anthony-treuillier-scality
Copy link
Contributor

No description provided.

@anthony-treuillier-scality anthony-treuillier-scality requested a review from a team as a code owner December 10, 2025 08:48
DESIGN.md Outdated
Comment on lines 28 to 30
* WithDetail: provide a message that details the error
* WithProperty: provide a key/value pair for additional informations (filename, path, username, ... )
* WithIdentifier: used to provide an identifer, it could be concatenated with other idenfier from previous calls from subfunctions (See example below for clarity)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put the With<Name> in verbatim style

DESIGN.md Outdated
Signature could be as follow

```go
errors.WithIdentifier(int):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You let an ending semicolon there

DESIGN.md Outdated
```go
errors.WithIdentifier(int):
errors.WithDetail(string)
errors.WithDetailf(string, ...any)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an extra space is here

DESIGN.md Outdated
Comment on lines 28 to 39
* WithDetail: provide a message that details the error
* WithProperty: provide a key/value pair for additional informations (filename, path, username, ... )
* WithIdentifier: used to provide an identifer, it could be concatenated with other idenfier from previous calls from subfunctions (See example below for clarity)

Signature could be as follow

```go
errors.WithIdentifier(int):
errors.WithDetail(string)
errors.WithDetailf(string, ...any)
errors.WithProperty(string, any)
```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put them in the same order

DESIGN.md Outdated
Comment on lines 44 to 89
```
forbidden (19-12-2): permission denied: missing required role: File='test.txt', User='john.doe', Role:'Reader', at=(func='main.appel3', file='main.go', line='270')
```

```go
package main

import (
"fmt"

errors "github.com/scality/go-errors"
)

var ErrForbidden = errors.New("forbidden")

func main(){
err := appel1()
fmt.Println(err)
}
func appel1() error {
return errors.Wrap(
appel2(),
errors.WithIdentifier(19),
)
}

func appel2() error {
return errors.Wrap(
appel3(),
errors.WithDetail("missing required role"),
errors.WithProperty("Role", "Reader"),
errors.WithProperty("User", "john.doe"),
errors.WithIdentifier(12),
)
}

func appel3() error {
// Something went wrong here
return errors.Wrap(
ErrForbidden,
errors.WithIdentifer(2),
errors.WithDetail("permission denied"),
errors.WithProperty("File", "test.txt"),
)
}
```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, I think it's better to put the error result after the code.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also missing a new line between main and appel1
Also also, I would rename appelX by funcX or foo bar baz, etc.

Signed-off-by: Anthony TREUILLIER <anthony.treuillier@scality.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants