@typespec/ts-http-runtime
Advanced tools
Comparing version
@@ -5,10 +5,14 @@ // Copyright (c) Microsoft Corporation. | ||
import { createHttpHeaders } from "../httpHeaders"; | ||
/** | ||
* Creates a rest error from a PathUnchecked response | ||
*/ | ||
export function createRestError(message, response) { | ||
export function createRestError(messageOrResponse, response) { | ||
var _a; | ||
const resp = typeof messageOrResponse === "string" ? response : messageOrResponse; | ||
const internalError = resp.body.error || resp.body; | ||
const message = typeof messageOrResponse === "string" | ||
? messageOrResponse | ||
: (_a = internalError.message) !== null && _a !== void 0 ? _a : `Unexpected status code: ${resp.status}`; | ||
return new RestError(message, { | ||
statusCode: statusCodeToNumber(response.status), | ||
request: response.request, | ||
response: toPipelineResponse(response), | ||
statusCode: statusCodeToNumber(resp.status), | ||
code: internalError.code, | ||
request: resp.request, | ||
response: toPipelineResponse(resp), | ||
}); | ||
@@ -15,0 +19,0 @@ } |
{ | ||
"name": "@typespec/ts-http-runtime", | ||
"version": "1.0.0-alpha.20231121.3", | ||
"version": "1.0.0-alpha.20231129.4", | ||
"description": "Isomorphic client library for making HTTP requests in node.js and browser.", | ||
@@ -5,0 +5,0 @@ "sdk-type": "client", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1083730
0.26%10302
0.12%