Skip to content

Commit c2223c9

Browse files
committed
fix: address violations
1 parent ccc6169 commit c2223c9

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/handler.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,27 @@ export async function requestAPI(
2525
try {
2626
response = await ServerConnection.makeRequest(requestUrl, init, settings);
2727
} catch (error) {
28-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
29-
throw new ServerConnection.NetworkError(error as any);
28+
throw new ServerConnection.NetworkError(
29+
error instanceof Error ? error : new Error(String(error))
30+
);
3031
}
3132

32-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
33-
let data: any = await response.text();
33+
let data: string | unknown = await response.text();
3434

35-
if (data.length > 0) {
35+
if (typeof data === 'string' && data.length > 0) {
3636
try {
3737
data = JSON.parse(data);
38-
} catch (error) {
38+
} catch {
3939
console.log('Not a JSON response body.', response);
4040
}
4141
}
4242

4343
if (!response.ok) {
44-
throw new ServerConnection.ResponseError(response, data.message ?? data);
44+
const errorMessage =
45+
data && typeof data === 'object' && 'message' in data
46+
? (data as { message: string }).message
47+
: String(data);
48+
throw new ServerConnection.ResponseError(response, errorMessage);
4549
}
4650

4751
return data;

0 commit comments

Comments
 (0)