mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2025-09-18 21:38:07 +00:00
implement printError function for frontend
This commit is contained in:
parent
45212cbd56
commit
c803228952
1 changed files with 14 additions and 0 deletions
|
@ -144,3 +144,17 @@ export function misskeyApiGet<
|
|||
|
||||
return promise;
|
||||
}
|
||||
|
||||
export function printError(error: unknown): string {
|
||||
if (error != null && typeof(error) === 'object') {
|
||||
if ('info' in error && typeof (error.info) === 'object' && error.info) {
|
||||
if ('e' in error.info && typeof (error.info.e) === 'object' && error.info.e) {
|
||||
if ('message' in error.info.e && typeof (error.info.e.message) === 'string') return error.info.e.message;
|
||||
if ('code' in error.info.e && typeof (error.info.e.code) === 'string') return error.info.e.code;
|
||||
if ('id' in error.info.e && typeof (error.info.e.id) === 'string') return error.info.e.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return String(error);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue