Skip to content

Commit 92b89d7

Browse files
committed
refactor(errors): improve error handling
- Created custom error class - Updated error classes to inherit - Improved error messages
1 parent 10759b7 commit 92b89d7

3 files changed

Lines changed: 37 additions & 26 deletions

File tree

dist/index.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Author: Taj <[email protected]>
77
* Homepage: https://github.com/taj54/universal-version-bump#readme
88
* License: MIT
9-
* Generated on Tue, 26 Aug 2025 13:43:36 GMT
9+
* Generated on Tue, 26 Aug 2025 13:59:07 GMT
1010
*/
1111
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
1212
/******/ var __webpack_modules__ = ({
@@ -32684,43 +32684,48 @@ exports.TARGET_PATH = core.getInput('target_path') || '.';
3268432684

3268532685
Object.defineProperty(exports, "__esModule", ({ value: true }));
3268632686
exports.InvalidManifestError = exports.FileNotFoundError = exports.VersionBumpError = exports.PlatformDetectionError = void 0;
32687+
/**
32688+
* Base class for custom errors.
32689+
*/
32690+
class CustomError extends Error {
32691+
constructor(message, name) {
32692+
super(message);
32693+
this.name = name;
32694+
}
32695+
}
3268732696
/**
3268832697
* Error thrown when platform detection fails.
3268932698
*/
32690-
class PlatformDetectionError extends Error {
32699+
class PlatformDetectionError extends CustomError {
3269132700
constructor(message) {
32692-
super(message);
32693-
this.name = 'PlatformDetectionError';
32701+
super(message, 'PlatformDetectionError');
3269432702
}
3269532703
}
3269632704
exports.PlatformDetectionError = PlatformDetectionError;
3269732705
/**
3269832706
* Error thrown when version bumping fails.
3269932707
*/
32700-
class VersionBumpError extends Error {
32708+
class VersionBumpError extends CustomError {
3270132709
constructor(message) {
32702-
super(message);
32703-
this.name = 'VersionBumpError';
32710+
super(message, 'VersionBumpError');
3270432711
}
3270532712
}
3270632713
exports.VersionBumpError = VersionBumpError;
3270732714
/**
3270832715
* Error thrown when a file is not found.
3270932716
*/
32710-
class FileNotFoundError extends Error {
32717+
class FileNotFoundError extends CustomError {
3271132718
constructor(message) {
32712-
super(message);
32713-
this.name = 'FileNotFoundError';
32719+
super(message, 'FileNotFoundError');
3271432720
}
3271532721
}
3271632722
exports.FileNotFoundError = FileNotFoundError;
3271732723
/**
3271832724
* Error thrown when a manifest file is invalid.
3271932725
*/
32720-
class InvalidManifestError extends Error {
32726+
class InvalidManifestError extends CustomError {
3272132727
constructor(message) {
32722-
super(message);
32723-
this.name = 'InvalidManifestError';
32728+
super(message, 'InvalidManifestError');
3272432729
}
3272532730
}
3272632731
exports.InvalidManifestError = InvalidManifestError;

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/errors.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
1+
/**
2+
* Base class for custom errors.
3+
*/
4+
class CustomError extends Error {
5+
constructor(message: string, name: string) {
6+
super(message);
7+
this.name = name;
8+
}
9+
}
10+
111
/**
212
* Error thrown when platform detection fails.
313
*/
4-
export class PlatformDetectionError extends Error {
14+
export class PlatformDetectionError extends CustomError {
515
constructor(message: string) {
6-
super(message);
7-
this.name = 'PlatformDetectionError';
16+
super(message, 'PlatformDetectionError');
817
}
918
}
1019

1120
/**
1221
* Error thrown when version bumping fails.
1322
*/
14-
export class VersionBumpError extends Error {
23+
export class VersionBumpError extends CustomError {
1524
constructor(message: string) {
16-
super(message);
17-
this.name = 'VersionBumpError';
25+
super(message, 'VersionBumpError');
1826
}
1927
}
2028

2129
/**
2230
* Error thrown when a file is not found.
2331
*/
24-
export class FileNotFoundError extends Error {
32+
export class FileNotFoundError extends CustomError {
2533
constructor(message: string) {
26-
super(message);
27-
this.name = 'FileNotFoundError';
34+
super(message, 'FileNotFoundError');
2835
}
2936
}
3037

3138
/**
3239
* Error thrown when a manifest file is invalid.
3340
*/
34-
export class InvalidManifestError extends Error {
41+
export class InvalidManifestError extends CustomError {
3542
constructor(message: string) {
36-
super(message);
37-
this.name = 'InvalidManifestError';
43+
super(message, 'InvalidManifestError');
3844
}
3945
}

0 commit comments

Comments
 (0)