Skip to content

Commit

Permalink
add extendParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
peze committed Nov 25, 2024
1 parent 2f38cb2 commit 488605c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
26 changes: 25 additions & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,28 @@ export class FileField extends Model {
}
}

export class ExtendsParameters extends Model {
headers?: { [key: string]: string };
queries?: { [key: string]: string };
static names(): { [key: string]: string } {
return {
headers: 'headers',
queries: 'queries',
};
}

static types(): { [key: string]: any } {
return {
headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
queries: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
};
}

constructor(map?: { [key: string]: any }) {
super(map);
}
}

export class RuntimeOptions extends Model {
retryOptions?: RetryOptions;
autoretry?: boolean;
Expand All @@ -407,9 +429,9 @@ export class RuntimeOptions extends Model {
noProxy?: string;
maxIdleConns?: number;
keepAlive?: boolean;
extendsParameters?: ExtendsParameters;
static names(): { [key: string]: string } {
return {
retryOptions: 'retryOptions',
autoretry: 'autoretry',
ignoreSSL: 'ignoreSSL',
key: 'key',
Expand All @@ -425,6 +447,7 @@ export class RuntimeOptions extends Model {
noProxy: 'noProxy',
maxIdleConns: 'maxIdleConns',
keepAlive: 'keepAlive',
extendsParameters: 'extendsParameters',
};
}

Expand All @@ -446,6 +469,7 @@ export class RuntimeOptions extends Model {
noProxy: 'string',
maxIdleConns: 'number',
keepAlive: 'boolean',
extendsParameters: ExtendsParameters,
};
}

Expand Down
10 changes: 2 additions & 8 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { RetryPolicyContext } from './retry';
export class BaseError extends Error {
name: string;
code: string;
message: string;

constructor(map: { [key: string]: any }) {
super(`${map.code}: ${map.message}`);
Expand Down Expand Up @@ -72,13 +71,8 @@ export function newError(data: any): ResponseError {
}

export function newUnretryableError(ctx: RetryPolicyContext | Request): Error {
if(ctx instanceof RetryPolicyContext) {
const message = ctx.exception ? ctx.exception.message : '';
const e = new UnretryableError(message);
e.data = {
lastRequest: ctx.httpRequest
};
return e;
if(ctx instanceof RetryPolicyContext && ctx.exception) {
return ctx.exception;
} else {
const e = new UnretryableError('');
e.data = {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export { default as File } from './file';
export { default as Form, FileFormStream } from './form';
export * from './func';
export * from './retry';
export { default as Stream } from './stream';
export { default as Stream, SSEEvent } from './stream';
export { default as URL } from './url';
export { default as XML } from './xml';

0 comments on commit 488605c

Please sign in to comment.