Skip to content

Commit 2802b9f

Browse files
committed
feat: 에러 타입 추가
1 parent 4fa5d9f commit 2802b9f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/utils/storage.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ const storage = window.localStorage;
33
export const setItem = (key: string, value: string) => {
44
try {
55
storage.setItem(key, value);
6-
} catch (error) {
7-
console.log(error);
6+
}
7+
catch (error: unknown) {
8+
if (error instanceof Error) console.log(error);
89
}
910
};
1011

@@ -14,7 +15,7 @@ export const getItem = <T>(key: string, defaultValue: T): T => {
1415
if (data) return JSON.parse(data);
1516
return defaultValue;
1617
} catch (error) {
17-
console.log(error);
18+
if (error instanceof Error) console.log(error);
1819
return defaultValue;
1920
}
2021
};

0 commit comments

Comments
 (0)