Skip to content

Commit 0c7159c

Browse files
committed
feat(search-attributes): improve error handling and naming
- Renamed `mutateSearchAttributes` to `humanizeSearchAttributes` for better clarity. - Simplified error handling by removing `isTemporalAPIError` check.
1 parent a7296eb commit 0c7159c

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/lib/services/search-attributes-service.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { ListSearchAttributesResponse } from '@temporalio/schemas';
22

33
import type { SearchAttributesResponseHumanized } from '$lib/types/workflows';
44
import { mapEntries } from '$lib/utilities/map-entries';
5-
import {
6-
isTemporalAPIError,
7-
requestFromAPI,
8-
} from '$lib/utilities/request-from-api';
5+
import { requestFromAPI } from '$lib/utilities/request-from-api';
96
import { routeForApi } from '$lib/utilities/route-for-api';
107
import { toSearchAttributeTypeReadable } from '$lib/utilities/screaming-enums';
118

@@ -18,7 +15,7 @@ export const fetchSearchAttributesForNamespace = async (
1815
const parsed = await parsedResponse({ namespace, request });
1916

2017
// parse the response to a human readable format
21-
return mutateSearchAttributes(parsed);
18+
return humanizeSearchAttributes(parsed);
2219
} catch (err) {
2320
// handle the error and return a default value
2421
handleError({ namespace, err });
@@ -43,7 +40,7 @@ async function parsedResponse({
4340
return ListSearchAttributesResponse.parse(searchAttributesResponse);
4441
}
4542

46-
function mutateSearchAttributes(
43+
function humanizeSearchAttributes(
4744
parsed: ListSearchAttributesResponse,
4845
): SearchAttributesResponseHumanized {
4946
return {
@@ -66,11 +63,7 @@ function handleError({
6663
namespace: string;
6764
err: unknown;
6865
}): SearchAttributesResponseHumanized {
69-
let message = 'Error fetching search attributes';
70-
if (isTemporalAPIError(err)) {
71-
message = 'Error fetching search attributes for namespace:';
72-
}
73-
66+
const message = 'Error fetching search attributes for namespace:';
7467
console.error(message, namespace, err);
7568

7669
return {

0 commit comments

Comments
 (0)