Skip to content

Commit 11b1318

Browse files
Merge pull request #539 from JorgenVatle/add-useful-errors
Add more insightful error messages for useFind and useGet
2 parents c75b3e4 + 930fdd1 commit 11b1318

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/useFind.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ export default function find<M extends Model = Model>(options: UseFindOptions):
6666
options
6767
)
6868

69+
if (!model) {
70+
throw new Error(
71+
`No model provided for useFind(). Did you define and register it with FeathersVuex?`
72+
)
73+
}
74+
6975
const getFetchParams = (providedParams?: Params | Ref<Params>): Params => {
7076
const provided = unwrapParams(providedParams)
7177

src/useGet.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ export default function get<M extends Model = Model>(options: UseGetOptions): Us
5454
options
5555
)
5656

57+
if (!model) {
58+
throw new Error(
59+
`No model provided for useGet(). Did you define and register it with FeathersVuex?`
60+
)
61+
}
62+
5763
function getId(): null | string | number {
5864
return isRef(id) ? id.value : id || null
5965
}

0 commit comments

Comments
 (0)