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

Prompt to create github issue on unhandled error #144

Open
arsen3d opened this issue Oct 28, 2018 · 0 comments
Open

Prompt to create github issue on unhandled error #144

arsen3d opened this issue Oct 28, 2018 · 0 comments

Comments

@arsen3d
Copy link

arsen3d commented Oct 28, 2018

The idea is if an error has not been handled in code, prompt user to submit the error code and callstack to github. This could be a setting only for alpha/beta releases.
Example:

f, err := os.Open("filename.ext")
if err != nil && reportError() {
    openbrowser("https://github.com/dispatchlabs/disgo/issues/new?title=Missing fil%20to%20invalid%20chain%3A%20%5Bunknown%2C%200%5D&body=%60%60%60%20%0AError%3A%20Launcher%20co")
}

func openbrowser(url string) {
	var err error

	switch runtime.GOOS {
	case "linux":
		err = exec.Command("xdg-open", url).Start()
	case "windows":
		err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
	case "darwin":
		err = exec.Command("open", url).Start()
	default:
		err = fmt.Errorf("unsupported platform")
	}
	if err != nil {
		log.Fatal(err)
	}

}
func reportError() bool {
	var response string
	_, err := fmt.Scanln(&response)
	if err != nil {
		log.Fatal(err)
	}
	okayResponses := []string{"y", "Y", "yes", "Yes", "YES"}
	nokayResponses := []string{"n", "N", "no", "No", "NO"}
	if containsString(okayResponses, response) {
		return true
	} else if containsString(nokayResponses, response) {
		return false
	} else {
		fmt.Println("Report error? Type yes or no and then press enter:")
		return reportError()
	}
}
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

1 participant