Skip to content

Commit

Permalink
Add ResponseSizeTooLarge Error (#3020)
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-codaio authored Jul 16, 2024
1 parent 70e1c9e commit c565969
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 5 deletions.
26 changes: 26 additions & 0 deletions api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,32 @@ export class MissingScopesError extends Error {
}
}

/**
* An error that will be thrown by {@link Fetcher.fetch} when the response body from the external system
* exceeds packs platform limits
*
* This error can be caught and retried by requesting less data from the external system through
* a smaller page size or omitting large fields.
*
* @hidden
*/
export class ResponseSizeTooLargeError extends Error {
/**
* The name of the error, for identification purposes.
*/
override name: string = 'ResponseSizeTooLargeError';

/** @hidden */
constructor(message?: string | undefined) {
super(message || 'Response size too large');
}

/** Returns if the error is an instance of ResponseSizeTooLargeError. Note that `instanceof` may not work. */
static isResponseSizeTooLargeError(err: any): err is ResponseSizeTooLargeError {
return 'name' in err && err.name === ResponseSizeTooLargeError.name;
}
}

/**
* A map of named property options methods for a particular sync table. The names need to match
* the values stored in the object schema. For the name, we use the property's name so that
Expand Down
19 changes: 18 additions & 1 deletion bundles/thunk_bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -5911,6 +5911,22 @@ module.exports = (() => {
};
__name(_MissingScopesError, "MissingScopesError");
var MissingScopesError = _MissingScopesError;
var _ResponseSizeTooLargeError = class _ResponseSizeTooLargeError extends Error {
/** @hidden */
constructor(message) {
super(message || "Response size too large");
/**
* The name of the error, for identification purposes.
*/
this.name = "ResponseSizeTooLargeError";
}
/** Returns if the error is an instance of ResponseSizeTooLargeError. Note that `instanceof` may not work. */
static isResponseSizeTooLargeError(err) {
return "name" in err && err.name === _ResponseSizeTooLargeError.name;
}
};
__name(_ResponseSizeTooLargeError, "ResponseSizeTooLargeError");
var ResponseSizeTooLargeError = _ResponseSizeTooLargeError;
function isDynamicSyncTable(syncTable) {
return "isDynamic" in syncTable;
}
Expand Down Expand Up @@ -6164,7 +6180,8 @@ module.exports = (() => {
var recognizableCodaErrorClasses2 = [
// StatusCodeError doesn't have the new StatusCodeError(message) constructor but it's okay.
StatusCodeError,
MissingScopesError
MissingScopesError,
ResponseSizeTooLargeError
];
function fixUncopyableTypes(val, pathPrefix, postTransforms, depth = 0) {
if (depth >= MaxTraverseDepth) {
Expand Down
19 changes: 19 additions & 0 deletions dist/api.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 25 additions & 1 deletion dist/api.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion dist/bundles/thunk_bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion dist/runtime/common/marshaling/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codahq/packs-sdk",
"version": "1.7.9",
"version": "1.7.9-prerelease.1",
"license": "MIT",
"workspaces": [
"dev/eslint"
Expand Down
2 changes: 2 additions & 0 deletions runtime/common/marshaling/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {CodaMarshalerType} from './constants';
import {MarshalingInjectedKeys} from './constants';
import {MissingScopesError} from '../../../api';
import {ResponseSizeTooLargeError} from '../../../api';
import {StatusCodeError} from '../../../api';
import {deserialize} from './serializer';
import {format} from 'util';
Expand Down Expand Up @@ -66,6 +67,7 @@ const recognizableCodaErrorClasses: ErrorConstructor[] = [
// StatusCodeError doesn't have the new StatusCodeError(message) constructor but it's okay.
StatusCodeError as any,
MissingScopesError as any,
ResponseSizeTooLargeError as any,
];

// pathPrefix can be temporarily modified, but needs to be restored to its original value
Expand Down

0 comments on commit c565969

Please sign in to comment.