Skip to content

Errorhelper

Max edited this page Jun 7, 2021 · 1 revision

This serves as an Errorhandler and also provides the log method used within the project.

InvalidRouteError

Takes a http.ResponseWriter and a pointer to a http.Request. This funtion will send an error message to the client with the http.ResponseWriter informing them that they will have to connect to /ws .
It does not return a value
Sample Usage:

ErrorHelper.InvalidRouteError(resp, req)

ConnectionNotWebsocketError

Takes a http.ResponseWriter and a pointer to a http.Request. This funtion will send an error message to the client with the http.ResponseWriter informing them that they will have to connect to via websocket. It will also inform them that the http(s) endpoint of speedrun.io is under a different domain.
It does not return a value.
Sample Usage:

ErrorHelper.ConnectionNotWebsocketError(resp, req)

OutputToConsole

This is the log function of the server. Depending on the mode provided it will color the output accordingly or leave it at the system default if no valid mode was provided.
It takes two strings, one representing the mode and the second being the message itself.
It does not return a value.
Currently features modes are:

  • Error - output is red
  • Warning - output is yellow
  • Update - output is green

Sample Usage of the command:

OutputToConsole("Error", "Something failed horribly)
Clone this wiki locally