mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-11 17:03:33 +00:00
handle owners not found in v2 endpoint
This commit is contained in:
parent
1739521666
commit
aaddc15acb
@ -10,7 +10,9 @@ import {
|
|||||||
IPartyProps,
|
IPartyProps,
|
||||||
IUserEntityMap
|
IUserEntityMap
|
||||||
} from 'wherehows-web/typings/api/datasets/party-entities';
|
} from 'wherehows-web/typings/api/datasets/party-entities';
|
||||||
|
import { ApiResponseStatus } from 'wherehows-web/utils/api';
|
||||||
import { datasetUrlById, datasetUrlByUrn } from 'wherehows-web/utils/api/datasets/shared';
|
import { datasetUrlById, datasetUrlByUrn } from 'wherehows-web/utils/api/datasets/shared';
|
||||||
|
import { ApiError } from 'wherehows-web/utils/api/errors/errors';
|
||||||
import { getJSON, postJSON } from 'wherehows-web/utils/api/fetcher';
|
import { getJSON, postJSON } from 'wherehows-web/utils/api/fetcher';
|
||||||
import { getApiRoot, ApiStatus } from 'wherehows-web/utils/api/shared';
|
import { getApiRoot, ApiStatus } from 'wherehows-web/utils/api/shared';
|
||||||
import { arrayFilter, arrayMap } from 'wherehows-web/utils/array';
|
import { arrayFilter, arrayMap } from 'wherehows-web/utils/array';
|
||||||
@ -120,8 +122,18 @@ const ownersWithModifiedTimeAsDate = arrayMap(ownerWithModifiedTimeAsDate);
|
|||||||
* @return {Promise<Array<IOwner>>}
|
* @return {Promise<Array<IOwner>>}
|
||||||
*/
|
*/
|
||||||
const readDatasetOwnersByUrn = async (urn: string): Promise<Array<IOwner>> => {
|
const readDatasetOwnersByUrn = async (urn: string): Promise<Array<IOwner>> => {
|
||||||
const { owners = [] } = await getJSON<Pick<IOwnerResponse, 'owners'>>({ url: datasetOwnersUrlByUrn(urn) });
|
let owners: Array<IOwner> = [];
|
||||||
return ownersWithModifiedTimeAsDate(owners);
|
|
||||||
|
try {
|
||||||
|
({ owners = [] } = await getJSON<Pick<IOwnerResponse, 'owners'>>({ url: datasetOwnersUrlByUrn(urn) }));
|
||||||
|
return ownersWithModifiedTimeAsDate(owners);
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ApiError && e.status === ApiResponseStatus.NotFound) {
|
||||||
|
return owners;
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user