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

[BUG] FormatMessageType returns empty string for unknown type #910

Closed
1 task done
ghost opened this issue Apr 6, 2024 · 3 comments
Closed
1 task done

[BUG] FormatMessageType returns empty string for unknown type #910

ghost opened this issue Apr 6, 2024 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented Apr 6, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

FormatMessageType returns the empty string for an unknown message type.

Expected Behavior

FormatMessageType should return the decimal representation of the type when the type is unknown.

Steps To Reproduce

 fmt.Println(websocket.FormatMessageType(7777))

Actual output: blank line
Expected output: 7777

Anything else?

Cc @rfyiamcool

@ghost ghost added the bug label Apr 6, 2024
@rfyiamcool
Copy link
Contributor

rfyiamcool commented Apr 7, 2024

@GreenMarmot

Do you want expected value when call fmt.Println(websocket.FormatMessageType(7777)) ? Currently input an unknown type, returns an empty string. 😁

I'm sorry, I don't understand your question. 😅

@bharat-rajani
Copy link

@rfyiamcool @GreenMarmot We can document the FormatMessageType function's expected return value through a descriptive Go doc comment

@bharat-rajani
Copy link

IMHO returning an empty string or the string representation of the opcode value (strconv.Itoa(input integer)) may not convey enough information about the error condition, potentially leading to more confusion or ambiguity.
I think returning a string like "InvalidOpcode", "InvalidMessageType", "unknown opcode" , would make function's behavior more explicit and easier to handle.

Let me know your thoughts!

@ghost ghost closed this as completed May 2, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants