Skip to content

don't panic inside the library #24

@ludusrusso

Description

@ludusrusso

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
}

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