Improve logs

This commit is contained in:
Ming Ming 2022-07-21 13:45:49 +08:00
parent f2dbc6db3b
commit 65c67a9af0
11 changed files with 45 additions and 24 deletions

View file

@ -118,7 +118,7 @@ Future<String> exchangePassword(Account account) async {
"[exchangePassword] Failed while requesting app password: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message: "Server responed with an error: HTTP ${response.statusCode}");
}
}

View file

@ -24,7 +24,8 @@ class FaceRemoteDataSource implements FaceDataSource {
_log.severe("[list] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final json = jsonDecode(response.body);

View file

@ -21,7 +21,8 @@ class FavoriteRemoteDataSource implements FavoriteDataSource {
_log.severe("[list] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final xml = XmlDocument.parse(response.body);

View file

@ -63,7 +63,8 @@ class FileWebdavDataSource implements FileDataSource {
_log.severe("[list] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final xml = XmlDocument.parse(response.body);
@ -114,7 +115,8 @@ class FileWebdavDataSource implements FileDataSource {
_log.severe("[remove] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
}
@ -126,7 +128,8 @@ class FileWebdavDataSource implements FileDataSource {
_log.severe("[getBinary] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
return response.body;
}
@ -140,7 +143,8 @@ class FileWebdavDataSource implements FileDataSource {
_log.severe("[putBinary] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
}
@ -185,7 +189,8 @@ class FileWebdavDataSource implements FileDataSource {
_log.severe("[updateProperty] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
}
@ -206,12 +211,14 @@ class FileWebdavDataSource implements FileDataSource {
_log.severe("[copy] Failed requesting sever: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
} else if (response.statusCode == 204) {
// conflict
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
}
@ -232,7 +239,8 @@ class FileWebdavDataSource implements FileDataSource {
_log.severe("[move] Failed requesting sever: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
}
@ -246,7 +254,8 @@ class FileWebdavDataSource implements FileDataSource {
_log.severe("[createDir] Failed requesting sever: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
}

View file

@ -18,7 +18,8 @@ class PersonRemoteDataSource implements PersonDataSource {
_log.severe("[list] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final json = jsonDecode(response.body);

View file

@ -72,7 +72,8 @@ class ShareRemoteDataSource implements ShareDataSource {
_log.severe("[create] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final json = jsonDecode(response.body);
@ -96,7 +97,8 @@ class ShareRemoteDataSource implements ShareDataSource {
_log.severe("[create] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final json = jsonDecode(response.body);
@ -113,7 +115,8 @@ class ShareRemoteDataSource implements ShareDataSource {
_log.severe("[delete] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
}
@ -122,7 +125,8 @@ class ShareRemoteDataSource implements ShareDataSource {
_log.severe("[_onListResult] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final json = jsonDecode(response.body);

View file

@ -20,7 +20,8 @@ class ShareeRemoteDataSource implements ShareeDataSource {
_log.severe("[list] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final json = jsonDecode(response.body);

View file

@ -24,7 +24,8 @@ class TagRemoteDataSource implements TagDataSource {
_log.severe("[list] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final xml = XmlDocument.parse(response.body);
@ -46,7 +47,8 @@ class TagRemoteDataSource implements TagDataSource {
_log.severe("[listByFile] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final xml = XmlDocument.parse(response.body);

View file

@ -24,7 +24,8 @@ class TaggedFileRemoteDataSource implements TaggedFileDataSource {
_log.severe("[list] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final xml = XmlDocument.parse(response.body);

View file

@ -11,7 +11,7 @@ String toUserString(dynamic exception) {
if (exception.response.statusCode == 401) {
return L10n.global().errorUnauthenticated;
} else if (exception.response.statusCode == 404) {
return "404 not found";
return "HTTP 404 not found";
} else if (exception.response.statusCode == 423) {
return L10n.global().errorLocked;
} else if (exception.response.statusCode == 500) {

View file

@ -16,7 +16,8 @@ class RequestPublicLink {
_log.severe("[call] Failed requesting server: $response");
throw ApiException(
response: response,
message: "Failed communicating with server: ${response.statusCode}");
message:
"Server responed with an error: HTTP ${response.statusCode}");
}
final JsonObj json = jsonDecode(response.body)["ocs"];
if (json["meta"]["statuscode"] != 200) {
@ -25,7 +26,7 @@ class RequestPublicLink {
throw ApiException(
response: response,
message:
"Failed communicating with server: ${json["meta"]["message"]}");
"Server responed with an error: HTTP ${json["meta"]["statuscode"]} ${json["meta"]["message"]}");
}
return json["data"]["url"];
}