Skip to content

Commit

Permalink
#192 [LS] - Stardardize Mumble errors propagation to the GUI.
Browse files Browse the repository at this point in the history
  • Loading branch information
steffano0 committed Jan 28, 2025
1 parent 4eb8f2e commit 0e1f640
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 156 deletions.
4 changes: 2 additions & 2 deletions client/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
errInvalidBinaryFile = errors.New("the defined binary file don't exists")
errBinaryAlreadyExists = errors.New("the binary already exists in the destination directory")
errDestinationIsNotADirectory = errors.New("the destination to copy the binary is not a directory")
errNoClientInConfiguredPath = errors.New("mumble binary not found in the configured path. Please ensure the path is correctly set and the binary is accessible.")
ErrNoClientInConfiguredPath = errors.New("mumble binary not found in the configured path")
)

type binary struct {
Expand Down Expand Up @@ -190,7 +190,7 @@ func searchBinaryInConf(conf *config.ApplicationConfig) func() (*binary, error)

b := isThereAnAvailableBinary(configuredPath)
if b == nil || b.lastError != nil {
return nil, errNoClientInConfiguredPath
return nil, ErrNoClientInConfiguredPath
}

return b, nil
Expand Down
2 changes: 1 addition & 1 deletion client/binary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func (s *clientSuite) Test_searchBinaryInConf_returnedCallbackFunctionReturnsAnE
binary, err := callBack()

c.Assert(binary, IsNil)
c.Assert(err, Equals, errNoClientInConfiguredPath)
c.Assert(err, Equals, ErrNoClientInConfiguredPath)
}

func (s *clientSuite) Test_searchBinaryInConf_returnsAValidFuncWhenANilConfIsProvided(c *C) {
Expand Down
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type databaseProvider func() []byte
// InitSystem do the checking of the current system looking
// for the appropriate Mumble binary and check for errors

var errBinaryUnavailable = errors.New("a valid Mumble binary is not available on your system")
var ErrBinaryUnavailable = errors.New("a valid Mumble binary is not available on your system")

func InitSystem(conf *config.ApplicationConfig, tor tor.Instance) Instance {
i := newMumbleClient(readerMumbleIniConfig, readerMumbleJSONConfig, readerMumbleDB, tor)
Expand All @@ -81,7 +81,7 @@ func InitSystem(conf *config.ApplicationConfig, tor tor.Instance) Instance {
}

if b == nil {
return invalidInstance(errBinaryUnavailable)
return invalidInstance(ErrBinaryUnavailable)
}

if b.shouldBeCopied {
Expand Down
2 changes: 1 addition & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (s *clientSuite) Test_InitSystem_returnsAnInvalidInstanceWhenAValidMumbleBi
client := i.(*client)

c.Assert(client.isValid, IsFalse)
c.Assert(client.err, Equals, errBinaryUnavailable)
c.Assert(client.err, Equals, ErrBinaryUnavailable)

ml.AssertExpectations(c)
}
Expand Down
139 changes: 72 additions & 67 deletions gui/catalog/catalog.go

Large diffs are not rendered by default.

21 changes: 8 additions & 13 deletions gui/locales/ar/out.gotext.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,14 @@
"fuzzy": true
},
{
"id": "Mumble client can't be used because:\n\n{Error}",
"message": "Mumble client can't be used because:\n\n{Error}",
"translation": "",
"placeholders": [
{
"id": "Error",
"string": "%[1]s",
"type": "string",
"underlyingType": "string",
"argNum": 1,
"expr": "err.Error()"
}
]
"id": "The configured path to the Mumble binary is not valid or can't be used.\n\nPlease configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"message": "The configured path to the Mumble binary is not valid or can't be used.\n\nPlease configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"translation": ""
},
{
"id": "No valid Mumble binary found in the system in order to run Wahay.",
"message": "No valid Mumble binary found in the system in order to run Wahay.",
"translation": ""
},
{
"id": "please enter a valid password",
Expand Down
27 changes: 10 additions & 17 deletions gui/locales/en/messages.gotext.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,23 +243,6 @@
"translatorComment": "Copied from source.",
"fuzzy": true
},
{
"id": "the Mumble client can not be used because: {Error}",
"message": "the Mumble client can not be used because: {Error}",
"translation": "The Mumble client can't be used because: {Error}",
"translatorComment": "Copied from source.",
"placeholders": [
{
"id": "Error",
"string": "%[1]s",
"type": "string",
"underlyingType": "string",
"argNum": 1,
"expr": "err.Error()"
}
],
"fuzzy": true
},
{
"id": "please enter a valid password",
"message": "please enter a valid password",
Expand Down Expand Up @@ -963,6 +946,16 @@
"id": "No valid Tor binary found in the system in order to run Wahay.",
"message": "No valid Tor binary found in the system in order to run Wahay.",
"translation": "No valid Tor binary found in the system in order to run Wahay."
},
{
"id": "No valid Mumble binary found in the system in order to run Wahay.",
"message": "No valid Mumble binary found in the system in order to run Wahay.",
"translation": "No valid Mumble binary found in the system in order to run Wahay."
},
{
"id": "The configured path to the Mumble binary is not valid or can't be used.\n\n Please configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"message": "The configured path to the Mumble binary is not valid or can't be used.\n\n Please configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"translation": "The configured path to the Mumble binary is not valid or can't be used.\n\n Please configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html"
}
]
}
21 changes: 8 additions & 13 deletions gui/locales/en/out.gotext.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,22 +207,17 @@
"fuzzy": true
},
{
"id": "Mumble client can't be used because:\n\n{Error}",
"message": "Mumble client can't be used because:\n\n{Error}",
"translation": "Mumble client can't be used because:\n\n{Error}",
"id": "The configured path to the Mumble binary is not valid or can't be used.\n\nPlease configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"message": "The configured path to the Mumble binary is not valid or can't be used.\n\nPlease configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"translation": "The configured path to the Mumble binary is not valid or can't be used.\n\nPlease configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"translatorComment": "Copied from source.",
"placeholders": [
{
"id": "Error",
"string": "%[1]s",
"type": "string",
"underlyingType": "string",
"argNum": 1,
"expr": "err.Error()"
}
],
"fuzzy": true
},
{
"id": "No valid Mumble binary found in the system in order to run Wahay.",
"message": "No valid Mumble binary found in the system in order to run Wahay.",
"translation": "No valid Mumble binary found in the system in order to run Wahay."
},
{
"id": "please enter a valid password",
"message": "please enter a valid password",
Expand Down
10 changes: 10 additions & 0 deletions gui/locales/es/messages.gotext.json
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,16 @@
"id": "No valid Tor binary found in the system in order to run Wahay.",
"message": "No valid Tor binary found in the system in order to run Wahay.",
"translation": "No se encontró un binario de Tor válido en el sistema para ejecutar Wahay."
},
{
"id": "No valid Mumble binary found in the system in order to run Wahay.",
"message": "No valid Mumble binary found in the system in order to run Wahay.",
"translation": "No se encontró un binario de Mumble válido en el sistema para ejecutar Wahay."
},
{
"id": "The configured path to the Mumble binary is not valid or can't be used.\n\n Please configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"message": "The configured path to the Mumble binary is not valid or can't be used.\n\n Please configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"translation": "La ruta configurada para el binario de Mumble no es válida o no se puede usar.\n\nPor favor, configura otra ruta o descarga un Wahay con Mumble incluido en el siguiente enlace:\n\nhttps://wahay.org/download.html"
}
]
}
21 changes: 8 additions & 13 deletions gui/locales/es/out.gotext.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,14 @@
"fuzzy": true
},
{
"id": "Mumble client can't be used because:\n\n{Error}",
"message": "Mumble client can't be used because:\n\n{Error}",
"translation": "",
"placeholders": [
{
"id": "Error",
"string": "%[1]s",
"type": "string",
"underlyingType": "string",
"argNum": 1,
"expr": "err.Error()"
}
]
"id": "The configured path to the Mumble binary is not valid or can't be used.\n\nPlease configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"message": "The configured path to the Mumble binary is not valid or can't be used.\n\nPlease configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"translation": ""
},
{
"id": "No valid Mumble binary found in the system in order to run Wahay.",
"message": "No valid Mumble binary found in the system in order to run Wahay.",
"translation": "No se encontró un binario de Mumble válido en el sistema para ejecutar Wahay."
},
{
"id": "please enter a valid password",
Expand Down
21 changes: 8 additions & 13 deletions gui/locales/fr/out.gotext.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,14 @@
"fuzzy": true
},
{
"id": "Mumble client can't be used because:\n\n{Error}",
"message": "Mumble client can't be used because:\n\n{Error}",
"translation": "",
"placeholders": [
{
"id": "Error",
"string": "%[1]s",
"type": "string",
"underlyingType": "string",
"argNum": 1,
"expr": "err.Error()"
}
]
"id": "The configured path to the Mumble binary is not valid or can't be used.\n\nPlease configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"message": "The configured path to the Mumble binary is not valid or can't be used.\n\nPlease configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"translation": ""
},
{
"id": "No valid Mumble binary found in the system in order to run Wahay.",
"message": "No valid Mumble binary found in the system in order to run Wahay.",
"translation": ""
},
{
"id": "please enter a valid password",
Expand Down
21 changes: 8 additions & 13 deletions gui/locales/sv/out.gotext.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,14 @@
"fuzzy": true
},
{
"id": "Mumble client can't be used because:\n\n{Error}",
"message": "Mumble client can't be used because:\n\n{Error}",
"translation": "",
"placeholders": [
{
"id": "Error",
"string": "%[1]s",
"type": "string",
"underlyingType": "string",
"argNum": 1,
"expr": "err.Error()"
}
]
"id": "The configured path to the Mumble binary is not valid or can't be used.\n\nPlease configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"message": "The configured path to the Mumble binary is not valid or can't be used.\n\nPlease configure another path or download a bundled Wahay with Mumble in the following url:\n\nhttps://wahay.org/download.html",
"translation": ""
},
{
"id": "No valid Mumble binary found in the system in order to run Wahay.",
"message": "No valid Mumble binary found in the system in order to run Wahay.",
"translation": ""
},
{
"id": "please enter a valid password",
Expand Down
11 changes: 10 additions & 1 deletion gui/mumble.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,14 @@ func init() {
}

func mumbleErrorTranslator(err error) string {
return i18n().Sprintf("Mumble client can't be used because:\n\n%s", err.Error())
switch err {
case client.ErrNoClientInConfiguredPath:
return i18n().Sprintf("The configured path to the Mumble binary is not valid or can't be used.\n\n" +
"Please configure another path or download a bundled Wahay with Mumble in the following url:" +
"\n\nhttps://wahay.org/download.html")
case client.ErrBinaryUnavailable:
return i18n().Sprintf("No valid Mumble binary found in the system in order to run Wahay.")
}

return err.Error()
}

0 comments on commit 0e1f640

Please sign in to comment.