File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change
1
+ export default class RequestIgnoredError extends Error { }
Original file line number Diff line number Diff line change 1
1
import { defineStore , type StoreDefinition } from 'pinia' ;
2
2
import { ID , ApiNames } from './types' ;
3
3
import createValidator from './validateResponse' ;
4
+ import RequestIgnoredError from './RequestIgnoredError' ;
4
5
5
6
type SortSettings = {
6
7
field : string ;
@@ -181,7 +182,9 @@ function createStore(
181
182
182
183
return api . get ( url , params ) . then ( ( res : any ) => {
183
184
if ( requestKey ) {
184
- if ( this . requestKeys [ requestKey ] !== startedAt ) return ;
185
+ if ( this . requestKeys [ requestKey ] !== startedAt ) {
186
+ throw new RequestIgnoredError ( ) ;
187
+ }
185
188
delete this . requestKeys [ requestKey ] ;
186
189
}
187
190
if ( settings . envelope === false ) {
Original file line number Diff line number Diff line change 1
1
import { computed , ref , useSlots } from 'vue' ;
2
2
import ServerError from './ServerError' ;
3
+ import RequestIgnoredError from './RequestIgnoredError' ;
3
4
4
5
export default function useFetchState ( loadOnUpdate : boolean ) {
5
6
const hasLoaded = ref ( false ) ;
@@ -14,6 +15,10 @@ export default function useFetchState(loadOnUpdate: boolean) {
14
15
const isFailed = computed ( ( ) => state . value === 'failed' ) ;
15
16
16
17
function handleError ( e : any ) {
18
+ if ( e instanceof RequestIgnoredError ) {
19
+ // The request was ignored, no error needed
20
+ return ;
21
+ }
17
22
if ( ! slots . failed ) {
18
23
if ( e . log ) {
19
24
e . log ( 'Fetch unhandled:' ) ;
You can’t perform that action at this time.
0 commit comments