Skip to content

Setting Expected errors on usecase.Interactor interface? #83

Answered by vearutop
jh125486 asked this question in Q&A
Discussion options

You must be logged in to vote

Ah, sorry, I misunderstood where you wanted to set errors. Interesting problem indeed.

I'm not sure HasInfo/SetInfo would help, because IOInteractor and IOInteractorOf are using value semantics, so they may be only accessible as copies and setters won't have expected effect. 🤔

But if you have a good idea how to make this work, I don't mind to have such accessors.

Conservatively, I would create a wrapper that overrides expected errors (and does not need to know about usecase.Info).
Please check this example:

package main

import (
	"context"
	"fmt"

	"github.com/swaggest/usecase"
	"github.com/swaggest/usecase/status"
)

func main() {
	u := usecase.NewInteractor(func(ctx context.Context, in s…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@jh125486
Comment options

Comment options

You must be logged in to vote
1 reply
@jh125486
Comment options

Answer selected by vearutop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants