UNPKG

trainingpeaks-sdk

Version:
36 lines (35 loc) 1.18 kB
import { ERROR_CODES } from './error-codes.js'; import { SDKError } from './sdk-error.js'; export class AuthenticationError extends SDKError { constructor(message, code = ERROR_CODES.AUTH_FAILED, context) { super(message, code, context); this.name = 'AuthenticationError'; } } export class ValidationError extends SDKError { constructor(message, field, code = ERROR_CODES.VALIDATION_FAILED) { super(message, code, { field }); this.name = 'ValidationError'; } get field() { return this.context?.field; } } export class WorkoutError extends SDKError { constructor(message, code = ERROR_CODES.WORKOUT_VALIDATION_FAILED, context) { super(message, code, context); this.name = 'WorkoutError'; } } export class NetworkError extends SDKError { constructor(message, code = ERROR_CODES.NETWORK_REQUEST_FAILED, context) { super(message, code, context); this.name = 'NetworkError'; } } export class UserError extends SDKError { constructor(message, code = ERROR_CODES.USER_FETCH_FAILED, context) { super(message, code, context); this.name = 'UserError'; } }