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

ASoC: Remove errorMsg and replace it with err type #36

Open
Delta456 opened this issue Aug 21, 2023 · 3 comments
Open

ASoC: Remove errorMsg and replace it with err type #36

Delta456 opened this issue Aug 21, 2023 · 3 comments

Comments

@Delta456
Copy link
Owner

There is a function errorMsg which prints to the stderr stream when there is an error. In production open must never print to stderr because it may conflict with other things present in the product, and can cause debugging to become very hard.

For example, the below code can be turned into:

// roundOffTitleColor rounds off 24 bit Color to the terminals maximum color capacity for Title.
func (b Box) roundOffTitleColor(col color.RGBColor, title string) string {
	switch detectTerminalColor() {
	case terminfo.ColorLevelNone:
		errorMsg("[warning]: terminal does not support colors, using no effects")
		return title
	case terminfo.ColorLevelMillions:
		return col.Sprint(title)
	default:
		return col.C256().Sprint(title)
	}
}
// roundOffTitleColor rounds off 24 bit Color to the terminals maximum color capacity for Title.
func (b Box) roundOffTitleColor(col color.RGBColor, title string) (string, err) {
	switch detectTerminalColor() {
	case terminfo.ColorLevelNone:
		return title, errors.New("terminal does not support colors")
	case terminfo.ColorLevelMillions:
		return col.Sprint(title), nil
	default:
		return col.C256().Sprint(title), nil
	}
}

then, do the changes as per the need.

This is a very breaking change so this has to be some with cautious.

@AniketNS
Copy link

Hey @Delta456, Can I work on this?

@Delta456
Copy link
Owner Author

Hey @Delta456, Can I work on this?

Sure

@AniketNS
Copy link

Hye @Delta456, I've created the PR, will you please check and tell me if this is correct or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants