Skip to content

Commit

Permalink
Use decodeOrThrow
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerry350 committed Jul 13, 2020
1 parent f159057 commit cc546d3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { fold } from 'fp-ts/lib/Either';
import { pipe } from 'fp-ts/lib/pipeable';
import { identity } from 'fp-ts/lib/function';
import { npStart } from '../../../../legacy_singletons';

import { decodeOrThrow } from '../../../../../common/runtime_types';
import {
getLogEntryAnomaliesDatasetsRequestPayloadRT,
getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT,
LOG_ANALYSIS_GET_LOG_ENTRY_ANOMALIES_DATASETS_PATH,
} from '../../../../../common/http_api/log_analysis';
import { createPlainError, throwErrors } from '../../../../../common/runtime_types';

export const callGetLogEntryAnomaliesDatasetsAPI = async (
sourceId: string,
Expand All @@ -36,8 +32,5 @@ export const callGetLogEntryAnomaliesDatasetsAPI = async (
),
});

return pipe(
getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT.decode(response),
fold(throwErrors(createPlainError), identity)
);
return decodeOrThrow(getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT)(response);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
Sort,
Pagination,
GetLogEntryAnomaliesRequestPayload,
AnomalyType,
} from '../../../common/http_api/log_analysis';
import type { MlSystem, MlAnomalyDetectors } from '../../types';
import { createLogEntryAnomaliesQuery, logEntryAnomaliesResponseRT } from './queries';
Expand Down

0 comments on commit cc546d3

Please sign in to comment.