Skip to content

Commit da2ba51

Browse files
committed
improve error message displaying
1 parent 282ba83 commit da2ba51

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

HwProj.APIGateway/HwProj.APIGateway.API/ExportServices/GoogleService.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,19 @@ public async Task<Result> Export(
7171
await updateRequest.ExecuteAsync();
7272
result = Result.Success();
7373
}
74-
catch (Exception e)
74+
catch (GoogleApiException ex)
7575
{
76-
result = Result.Failed($"Ошибка: {e.Message}");
76+
var message = $"Ошибка при обращении к Google Sheets: {ex.Message}";
77+
if (ex.Error.Code == (int)HttpStatusCode.NotFound)
78+
{
79+
message = "Таблица не найдена, проверьте корректность ссылки";
80+
}
81+
else if (ex.Error.Code == (int)HttpStatusCode.Forbidden)
82+
{
83+
message = "Нет прав не редактирование таблицы, проверьте настройки доступа";
84+
}
85+
86+
return Result.Failed(message);
7787
}
7888

7989
return result;
@@ -99,7 +109,7 @@ public async Task<Result<string[]>> GetSheetTitles(string sheetUrl)
99109
}
100110
else if (ex.Error.Code == (int)HttpStatusCode.Forbidden)
101111
{
102-
message = "Нет прав не редактирование таблицы, проверьте настройки доступа";
112+
message = "Нет прав не получение данных о таблице, проверьте настройки доступа";
103113
}
104114

105115
return Result<string[]>.Failed(message);

0 commit comments

Comments
 (0)