mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-12 22:31:39 +01:00
* adds error handling for control groups to api service as post request middleware * adds waitFor to async middleware in api service to attempt to fix race conditions in tests Co-authored-by: Jordan Reimer <zofskeez@gmail.com>
25 lines
645 B
TypeScript
25 lines
645 B
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { ResponseError } from '@hashicorp/vault-client-typescript';
|
|
|
|
export const getErrorResponse = <T>(error?: T, status?: number) => {
|
|
const e = error || {
|
|
errors: ['first error', 'second error'],
|
|
message: 'there were some errors',
|
|
};
|
|
// url is readonly on Response so mock it and cast to Response type
|
|
const response = {
|
|
status: status || 404,
|
|
url: `${document.location.origin}/v1/test/error/parsing`,
|
|
json: () => Promise.resolve(e),
|
|
} as Response;
|
|
|
|
return new ResponseError({
|
|
...response,
|
|
clone: () => response,
|
|
});
|
|
};
|