Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't panic inside the library #24

Open
ludusrusso opened this issue Apr 28, 2022 · 2 comments
Open

don't panic inside the library #24

ludusrusso opened this issue Apr 28, 2022 · 2 comments

Comments

@ludusrusso
Copy link

I'm not a fun of using panic inside a client library, this could lead to unexpected crashes of code using the library.

vt-go/vt.go

Lines 74 to 79 in e010bf4

if err != nil {
msg := fmt.Sprintf(
"error formatting URL \"%s\": %s",
pathFmt, err)
panic(msg)
}

What about creating a new method like this?

func NewURL(pathFmt string, a ...interface{}) (*url.URLm, error) {
	path := fmt.Sprintf(pathFmt, a...)
	url, err := url.Parse(path)
	if err != nil {
		return nil, fmt.Errorf(
			"error formatting URL \"%s\": %s",
			pathFmt, err)
	}
	return baseURL.ResolveReference(url), nil
}
@ludusrusso
Copy link
Author

Also, all the Must* functions defined in https://github.com/VirusTotal/vt-go/blob/master/object.go are potentially dangerous, I suggest to deprecated them since they are not used in the main library!

@mgmacias95
Copy link
Member

Hello @ludusrusso,

Thank you for your suggestion. Feel free to make a contribution to fix the problem :).

Regards,
Marta

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

No branches or pull requests

2 participants