pr-sizewise
Version:
A CLI tool that measures and reports pull request sizes for GitHub and GitLab, helping teams maintain manageable code changes.
84 lines • 2.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidationError = exports.APIError = exports.PlatformError = exports.AuthError = exports.ConfigError = exports.SizeWiseError = void 0;
exports.handleError = handleError;
/**
* Base error class for SizeWise errors
*/
class SizeWiseError extends Error {
constructor(message, code) {
super(message);
this.code = code;
this.name = 'SizeWiseError';
}
}
exports.SizeWiseError = SizeWiseError;
/**
* Configuration related errors
*/
class ConfigError extends SizeWiseError {
constructor(message) {
super(message, 'CONFIG_ERROR');
this.name = 'ConfigError';
}
}
exports.ConfigError = ConfigError;
/**
* Authentication related errors
*/
class AuthError extends SizeWiseError {
constructor(message) {
super(message, 'AUTH_ERROR');
this.name = 'AuthError';
}
}
exports.AuthError = AuthError;
/**
* Platform/Provider related errors
*/
class PlatformError extends SizeWiseError {
constructor(message) {
super(message, 'PLATFORM_ERROR');
this.name = 'PlatformError';
}
}
exports.PlatformError = PlatformError;
/**
* API related errors
*/
class APIError extends SizeWiseError {
constructor(message, statusCode) {
super(message, 'API_ERROR');
this.statusCode = statusCode;
this.name = 'APIError';
}
}
exports.APIError = APIError;
/**
* Validation related errors
*/
class ValidationError extends SizeWiseError {
constructor(message) {
super(message, 'VALIDATION_ERROR');
this.name = 'ValidationError';
}
}
exports.ValidationError = ValidationError;
/**
* Error handler function that processes errors and returns appropriate error messages
*/
function handleError(error) {
if (error instanceof SizeWiseError) {
return {
message: error.message,
code: error.code,
};
}
// Handle generic errors
const message = error instanceof Error ? error.message : String(error);
return {
message,
code: 'UNKNOWN_ERROR',
};
}
//# sourceMappingURL=errors.js.map