Skip to content

Commit

Permalink
feat(blog2): improve thrown error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Apr 5, 2022
1 parent bd782c2 commit 7be774a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/blog2/src/client/composables/useBlogCategory.ts
Expand Up @@ -34,6 +34,16 @@ export const useBlogCategory = <
"";

const routes = router.getRoutes();

if (!blogCategoryMap.value[mapKey])
throw new Error(
`useBlogCategory: ${
key
? `key ${key} is invalid`
: "can not bind to an exisiting key on non blog pages"
}`
);

const currentMap = blogCategoryMap.value[mapKey][routeLocale.value];
const result: BlogCategoryData<T> = {
path: currentMap.path,
Expand Down
9 changes: 9 additions & 0 deletions packages/blog2/src/client/composables/useBlogType.ts
Expand Up @@ -32,6 +32,15 @@ export const useBlogType = <
?.key ||
"";

if (!blogTypeMap.value[mapKey])
throw new Error(
`useBlogType: ${
key
? `key ${key} is invalid`
: "can not bind to an exisiting key on non blog pages"
}`
);

const routes = router.getRoutes();
const configMap = blogTypeMap.value[mapKey][routeLocale.value];
const result: BlogTypeData<T> = {
Expand Down

0 comments on commit 7be774a

Please sign in to comment.