Skip to content

Commit c75d2e3

Browse files
mahirshahchriseppstein
authored andcommitted
Make error classes public.
1 parent 024c631 commit c75d2e3

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

css-property-parser.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
export = CssPropertyParser;
22

33
declare namespace CssPropertyParser {
4+
class ParseError extends Error {
5+
}
6+
class UnsupportedPropertyError extends Error {
7+
readonly property: string;
8+
constructor(property: string);
9+
}
10+
class UnknownPropertyError extends Error {
11+
readonly property: string;
12+
constructor(property: string);
13+
}
414
interface Declarations {
515
[property: string]: string;
616
}

src/errors/UnknownPropertyError.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
module.exports = class UnknownPropertyError extends Error {
66
constructor(property) {
77
super(`Unknown property error: ${property} is not a known property`);
8+
this._property = property;
89
Error.captureStackTrace(this, UnknownPropertyError);
910
}
11+
get property() {
12+
return this._property;
13+
}
1014
};

src/errors/UnsupportedPropertyError.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
module.exports = class UnsupportedPropertyError extends Error {
77
constructor(property) {
88
super(`Unsupported property error: ${property} is not a supported property`);
9+
this._property = property;
910
Error.captureStackTrace(this, UnsupportedPropertyError);
1011
}
12+
get property() {
13+
return this._property;
14+
}
1115
};

src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@ const getShorthandComputedProperties = require('./getShorthandComputedProperties
33
const isShorthandProperty = require('./isShorthandProperty');
44
const getShorthandsForProperty = require('./getShorthandsForProperty');
55
const isValidDeclaration = require('./isValidDeclaration');
6+
const {
7+
ParseError,
8+
UnsupportedPropertyError,
9+
UnknownPropertyError,
10+
} = require('./errors');
611

712
module.exports = {
813
expandShorthandProperty,
914
getShorthandComputedProperties,
1015
isShorthandProperty,
1116
isValidDeclaration,
1217
getShorthandsForProperty,
18+
ParseError,
19+
UnsupportedPropertyError,
20+
UnknownPropertyError,
1321
};

0 commit comments

Comments
 (0)