diff options
Diffstat (limited to 'src/vs/platform/request/common/request.ts')
-rw-r--r-- | src/vs/platform/request/common/request.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/vs/platform/request/common/request.ts b/src/vs/platform/request/common/request.ts index d217ccb1f67..15f9d6d94d0 100644 --- a/src/vs/platform/request/common/request.ts +++ b/src/vs/platform/request/common/request.ts @@ -30,9 +30,6 @@ function hasNoContent(context: IRequestContext): boolean { } export async function asText(context: IRequestContext): Promise<string | null> { - if (!isSuccess(context)) { - throw new Error('Server returned ' + context.res.statusCode); - } if (hasNoContent(context)) { return null; } @@ -40,6 +37,13 @@ export async function asText(context: IRequestContext): Promise<string | null> { return buffer.toString(); } +export async function asTextOrError(context: IRequestContext): Promise<string | null> { + if (!isSuccess(context)) { + throw new Error('Server returned ' + context.res.statusCode); + } + return asText(context); +} + export async function asJson<T = {}>(context: IRequestContext): Promise<T | null> { if (!isSuccess(context)) { throw new Error('Server returned ' + context.res.statusCode); |