Skip to content

Commit

Permalink
Export the ErrorInfo class
Browse files Browse the repository at this point in the history
So that wrapper SDKs like Spaces can use the ErrorInfo class.

Signed-off-by: Lewis Marshall <[email protected]>
  • Loading branch information
lmars committed Aug 23, 2023
1 parent cfdeda0 commit d96c33d
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ably.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ declare namespace Types {
/**
* A generic Ably error object that contains an Ably-specific status code, and a generic status code. Errors returned from the Ably server are compatible with the `ErrorInfo` structure and should result in errors that inherit from `ErrorInfo`.
*/
interface ErrorInfo extends Error {
class ErrorInfo extends Error {
/**
* Ably [error code](https://github.com/ably/ably-common/blob/main/protocol/errors.json).
*/
Expand All @@ -743,6 +743,20 @@ declare namespace Types {
* HTTP Status Code corresponding to this error, where applicable.
*/
statusCode: number;
/**
* The underlying cause of the error, where applicable.
*/
cause?: string | Error | ErrorInfo;

/**
* Construct an ErrorInfo object.
*
* @param message - A string describing the error.
* @param code - Ably [error code](https://github.com/ably/ably-common/blob/main/protocol/errors.json).
* @param statusCode - HTTP Status Code corresponding to this error.
* @param cause - The underlying cause of the error.
*/
constructor(message: string, code: number, statusCode: number, cause?: string | Error | ErrorInfo);
}

/**
Expand Down Expand Up @@ -3769,3 +3783,8 @@ export declare class Rest extends Types.RestCallbacks {}
* A client that extends the functionality of {@link Rest} and provides additional realtime-specific features.
*/
export declare class Realtime extends Types.RealtimeCallbacks {}

/**
* A generic Ably error object that contains an Ably-specific status code, and a generic status code. Errors returned from the Ably server are compatible with the `ErrorInfo` structure and should result in errors that inherit from `ErrorInfo`.
*/
export declare class ErrorInfo extends Types.ErrorInfo {}
4 changes: 4 additions & 0 deletions promises.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export declare class Rest extends Ably.Rest.Promise {}
* A client that extends the functionality of {@link Rest} and provides additional realtime-specific features.
*/
export declare class Realtime extends Ably.Realtime.Promise {}
/**
* A generic Ably error object that contains an Ably-specific status code, and a generic status code. Errors returned from the Ably server are compatible with the `ErrorInfo` structure and should result in errors that inherit from `ErrorInfo`.
*/
export declare class ErrorInfo extends Types.ErrorInfo {}

// Re-export the Types namespace.
import Types = Ably.Types;
Expand Down
1 change: 1 addition & 0 deletions promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var RealtimePromise = function (options) {
Object.assign(RealtimePromise, Ably.Realtime);

module.exports = {
ErrorInfo: Ably.ErrorInfo,
Rest: RestPromise,
Realtime: RealtimePromise,
};
2 changes: 2 additions & 0 deletions src/platform/nativescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Rest from '../../common/lib/client/rest';
import Realtime from '../../common/lib/client/realtime';
import Platform from '../../common/platform';
import ErrorInfo from '../../common/lib/types/errorinfo';

// Platform Specific
import BufferUtils from '../web/lib/util/bufferutils';
Expand Down Expand Up @@ -41,6 +42,7 @@ if (Platform.Config.agent) {
}

export default {
ErrorInfo,
Rest,
Realtime,
msgpack,
Expand Down
2 changes: 2 additions & 0 deletions src/platform/nodejs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Rest from '../../common/lib/client/rest';
import Realtime from '../../common/lib/client/realtime';
import Platform from '../../common/platform';
import ErrorInfo from '../../common/lib/types/errorinfo';

// Platform Specific
import BufferUtils from './lib/util/bufferutils';
Expand Down Expand Up @@ -35,6 +36,7 @@ if (Platform.Config.agent) {
}

export default {
ErrorInfo,
Rest,
Realtime,
msgpack: null,
Expand Down
2 changes: 2 additions & 0 deletions src/platform/react-native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Rest from '../../common/lib/client/rest';
import Realtime from '../../common/lib/client/realtime';
import Platform from '../../common/platform';
import ErrorInfo from '../../common/lib/types/errorinfo';

// Platform Specific
import BufferUtils from '../web/lib/util/bufferutils';
Expand Down Expand Up @@ -39,6 +40,7 @@ if (Platform.Config.agent) {
}

export default {
ErrorInfo,
Rest,
Realtime,
msgpack,
Expand Down
2 changes: 2 additions & 0 deletions src/platform/web-noencryption/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Rest from '../../common/lib/client/rest';
import Realtime from '../../common/lib/client/realtime';
import Platform from '../../common/platform';
import ErrorInfo from '../../common/lib/types/errorinfo';

// Platform Specific
import BufferUtils from '../web/lib/util/bufferutils';
Expand Down Expand Up @@ -36,6 +37,7 @@ if (Platform.Config.agent) {
}

export default {
ErrorInfo,
Rest,
Realtime,
msgpack,
Expand Down
2 changes: 2 additions & 0 deletions src/platform/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Rest from '../../common/lib/client/rest';
import Realtime from '../../common/lib/client/realtime';
import Platform from '../../common/platform';
import ErrorInfo from '../../common/lib/types/errorinfo';

// Platform Specific
import BufferUtils from './lib/util/bufferutils';
Expand Down Expand Up @@ -47,6 +48,7 @@ if (Platform.Config.noUpgrade) {
}

export default {
ErrorInfo,
Rest,
Realtime,
msgpack,
Expand Down

0 comments on commit d96c33d

Please sign in to comment.