mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 00:03:58 +01:00
Locale: reports API failure messages
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/stringUtils.h"
|
||||
#include "detection/locale/locale.h"
|
||||
#include "modules/locale/locale.h"
|
||||
|
||||
@@ -8,10 +7,10 @@ bool ffPrintLocale(FFLocaleOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY locale = ffStrbufCreate();
|
||||
|
||||
ffDetectLocale(&locale);
|
||||
if(locale.length == 0)
|
||||
const char* error = ffDetectLocale(&locale);
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No locale found");
|
||||
ffPrintError(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,7 +51,14 @@ bool ffGenerateLocaleJsonResult(FF_MAYBE_UNUSED FFLocaleOptions* options, yyjson
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY locale = ffStrbufCreate();
|
||||
|
||||
ffDetectLocale(&locale);
|
||||
const char* error = ffDetectLocale(&locale);
|
||||
|
||||
if(error)
|
||||
{
|
||||
yyjson_mut_obj_add_str(doc, module, "error", error);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(locale.length == 0)
|
||||
{
|
||||
yyjson_mut_obj_add_str(doc, module, "error", "No locale found");
|
||||
|
||||
Reference in New Issue
Block a user