mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-07 21:36:26 +02:00
* fill out test coverage before replacing component * rename page error selectors * delete unused templates * render Page::Error in vault.cluster.not-found * replace NotFound component with Page::Error * support full page errors for Page::Error component * finish updating getErrorResponse usage and remove "not found" message * delete unused template and route * cleanup unused selectors * whoops, missed this test update Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
31 lines
765 B
TypeScript
31 lines
765 B
TypeScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { ResponseError } from '@hashicorp/vault-client-typescript';
|
|
|
|
const DEFAULT_ERROR = {
|
|
errors: ['first error', 'second error'],
|
|
message: 'there were some errors',
|
|
};
|
|
|
|
const EMPTY_ERROR = { errors: [] };
|
|
|
|
export const getErrorResponse = (error = DEFAULT_ERROR, status = 404) => {
|
|
// 404 responses do not return any errors
|
|
const e = status === 404 ? EMPTY_ERROR : error;
|
|
|
|
// url is readonly on Response so mock it and cast to Response type
|
|
const response = {
|
|
status,
|
|
url: `${document.location.origin}/v1/test/error/parsing`,
|
|
json: () => Promise.resolve(e),
|
|
} as Response;
|
|
|
|
return new ResponseError({
|
|
...response,
|
|
clone: () => response,
|
|
});
|
|
};
|