Skip to content

Commit

Permalink
Merge pull request #454 from convoyinc/gfoltz/throwUnsatisfied
Browse files Browse the repository at this point in the history
Throw UnsatisifiedCacheError on cache restore instead of generic error
  • Loading branch information
gfoltz committed Apr 1, 2021
2 parents 8ff8af1 + f10812d commit 18663f0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Cache.ts
Expand Up @@ -11,6 +11,7 @@ import { Queryable } from './Queryable';
import { ChangeId, NodeId, RawOperation, Serializable } from './schema';
import { DocumentNode, setsHaveSomeIntersection } from './util';
import { QueryResult } from './operations/read';
import { UnsatisfiedCacheError } from './errors';

export { MigrationMap };
export type TransactionCallback = (transaction: CacheTransaction) => void;
Expand Down Expand Up @@ -46,7 +47,7 @@ export class Cache implements Queryable {
const { cacheSnapshot, editedNodeIds } = restore(data, this._context);
const migrated = migrate(cacheSnapshot, migrationMap);
if (verifyQuery && !read(this._context, verifyQuery, migrated.baseline, false).complete) {
throw new Error(`Restored cache cannot satisfy the verification query`);
throw new UnsatisfiedCacheError(`Restored cache cannot satisfy the verification query`);
}
this._setSnapshot(migrated, editedNodeIds);
}
Expand Down

0 comments on commit 18663f0

Please sign in to comment.