@hasura/ndc-sdk-typescript
Version:
This SDK is mostly analogous to the Rust SDK, except where necessary.
66 lines • 2.91 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BadGateway = exports.NotSupported = exports.InternalServerError = exports.UnprocessableContent = exports.Conflict = exports.Forbidden = exports.BadRequest = exports.ConnectorError = void 0;
class ConnectorError extends Error {
statusCode;
details;
constructor(statusCode, message, details) {
super(message);
this.statusCode = statusCode;
if (details !== undefined) {
this.details = details;
}
return this;
}
}
exports.ConnectorError = ConnectorError;
/** The request did not match the data connector's expectation based on this specification */
class BadRequest extends ConnectorError {
constructor(message, details) {
super(400, message, details);
}
}
exports.BadRequest = BadRequest;
/** The request could not be handled because a permission check failed - for example, a mutation might fail because a check constraint was not met */
class Forbidden extends ConnectorError {
constructor(message, details) {
super(403, message, details);
}
}
exports.Forbidden = Forbidden;
/** The request could not be handled because it would create a conflicting state for the data source - for example, a mutation might fail because a foreign key constraint was not met */
class Conflict extends ConnectorError {
constructor(message, details) {
super(409, message, details);
}
}
exports.Conflict = Conflict;
/** The request could not be handled because, while the request was well-formed, it was not semantically correct. For example, a value for a custom scalar type was provided, but with an incorrect type */
class UnprocessableContent extends ConnectorError {
constructor(message, details) {
super(422, message, details);
}
}
exports.UnprocessableContent = UnprocessableContent;
/** The request could not be handled because of an error on the server */
class InternalServerError extends ConnectorError {
constructor(message, details) {
super(500, message, details);
}
}
exports.InternalServerError = InternalServerError;
/** The request could not be handled because it relies on an unsupported capability. Note: this ought to indicate an error on the caller side, since the caller should not generate requests which are incompatible with the indicated capabilities */
class NotSupported extends ConnectorError {
constructor(message, details) {
super(501, message, details);
}
}
exports.NotSupported = NotSupported;
/** The request could not be handled because an upstream service was unavailable or returned an unexpected response, e.g., a connection to a database server failed */
class BadGateway extends ConnectorError {
constructor(message, details) {
super(502, message, details);
}
}
exports.BadGateway = BadGateway;
//# sourceMappingURL=error.js.map