@@ -31,6 +31,7 @@ const CONFIG_DEFAULT: ConfigMap = Object.freeze({
31
31
* @param props.key
32
32
* @param props.value
33
33
* @return `null` if the value is valid, or an error message otherwise.
34
+ * @throws {Error } If the config item cannot be managed by these config utilities.
34
35
*/
35
36
const testConfig = ( { key, value} : ConfigUpdate ) : Nullable < string > => {
36
37
let result = null ;
@@ -41,7 +42,7 @@ const testConfig = ({key, value}: ConfigUpdate): Nullable<string> => {
41
42
}
42
43
break ;
43
44
case CONFIG_KEY . THEME :
44
- throw new Error ( `${ key } should be handled by JoyUI instead .` ) ;
45
+ throw new Error ( `" ${ key } " cannot be managed using these utilities .` ) ;
45
46
case CONFIG_KEY . PAGE_SIZE :
46
47
if ( 0 >= value || MAX_PAGE_SIZE < value ) {
47
48
result = `Page size must be greater than 0 and less than ${ MAX_PAGE_SIZE + 1 } .` ;
@@ -61,6 +62,7 @@ const testConfig = ({key, value}: ConfigUpdate): Nullable<string> => {
61
62
* @param props.key
62
63
* @param props.value
63
64
* @return `null` if the update succeeds, or an error message otherwise.
65
+ * @throws {Error } If the config item cannot be managed by these config utilities.
64
66
*/
65
67
const setConfig = ( { key, value} : ConfigUpdate ) : Nullable < string > => {
66
68
const error = testConfig ( { key, value} as ConfigUpdate ) ;
@@ -86,7 +88,7 @@ const setConfig = ({key, value}: ConfigUpdate): Nullable<string> => {
86
88
) ;
87
89
break ;
88
90
case CONFIG_KEY . THEME :
89
- throw new Error ( `${ key } should be handled by JoyUI instead .` ) ;
91
+ throw new Error ( `" ${ key } " cannot be managed using these utilities .` ) ;
90
92
case CONFIG_KEY . PAGE_SIZE :
91
93
window . localStorage . setItem ( LOCAL_STORAGE_KEY . PAGE_SIZE , value . toString ( ) ) ;
92
94
break ;
@@ -101,6 +103,7 @@ const setConfig = ({key, value}: ConfigUpdate): Nullable<string> => {
101
103
*
102
104
* @param key
103
105
* @return The value.
106
+ * @throws {Error } If the config item cannot be managed by these config utilities.
104
107
*/
105
108
const getConfig = < T extends CONFIG_KEY > ( key : T ) : ConfigMap [ T ] => {
106
109
let value = null ;
@@ -121,7 +124,7 @@ const getConfig = <T extends CONFIG_KEY>(key: T): ConfigMap[T] => {
121
124
} as DecoderOptionsType ;
122
125
break ;
123
126
case CONFIG_KEY . THEME :
124
- throw new Error ( `${ key } should be handled by JoyUI instead .` ) ;
127
+ throw new Error ( `" ${ key } " cannot be managed using these utilities .` ) ;
125
128
case CONFIG_KEY . PAGE_SIZE :
126
129
value = window . localStorage . getItem ( LOCAL_STORAGE_KEY . PAGE_SIZE ) ;
127
130
break ;
0 commit comments