Skip to content

Commit

Permalink
Fix ocr errors showing as [object Object]
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-va committed Oct 28, 2024
1 parent 0c9749b commit 33cfe57
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/server-asset-sg/src/features/files/file-ocr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ const makeResponseError = async (response: Response): Promise<Error> => {
if (hasKey(data, 'message')) {
data = data.message;
}
} else if (hasKey(data, 'message')) {
data = data.message;
}
return new Error(`${response.status} ${response.statusText} - ${data ?? body}`);
data = data ?? body;
const message = typeof data === 'string' ? data : JSON.stringify(data);
return new Error(`${response.status} ${response.statusText} - ${message}`);
};

const hasKey = <K extends string>(value: unknown, key: K): value is { [k in K]: unknown } => {
Expand Down

0 comments on commit 33cfe57

Please sign in to comment.