Merge pull request 'fix(logs): Implement json encode error handling' (#570) from naiji/ssh-key-rendering-error into master

Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy.org.app/pulls/570
Reviewed-by: Inex Code <inex.code@selfprivacy.org>
This commit is contained in:
NaiJi ✨ 2024-08-26 11:57:18 +03:00
commit ef8ca84263

View file

@ -101,12 +101,19 @@ class ConsoleInterceptor extends InterceptorsWrapper {
) async {
final Response? response = err.response;
String responseEncoded = '';
try {
responseEncoded = jsonEncode(response);
} catch (e) {
responseEncoded = response?.statusMessage ?? responseEncoded;
}
addConsoleLog(
ManualConsoleLog.warning(
customTitle: 'RestAPI error',
content: '"uri": "${response?.realUri}",\n'
'"status_code": ${response?.statusCode},\n'
'"response": ${jsonEncode(response)}',
'"response": $responseEncoded',
),
);
return super.onError(err, handler);