Skip to content

Commit

Permalink
feat: add PolymeshError typeguard
Browse files Browse the repository at this point in the history
  • Loading branch information
monitz87 committed Aug 17, 2020
1 parent 212ab8a commit e07bdd8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/base/types.ts
@@ -1,5 +1,16 @@
import { PolymeshError as PolymeshErrorClass } from './PolymeshError';
import { PolymeshTransaction as PolymeshTransactionClass } from './PolymeshTransaction';
import { TransactionQueue as TransactionQueueClass } from './TransactionQueue';

export type PolymeshTransaction = InstanceType<typeof PolymeshTransactionClass>;
export type TransactionQueue = InstanceType<typeof TransactionQueueClass>;
export type PolymeshError = InstanceType<typeof PolymeshErrorClass>;

/**
* @hidden
*/
export function isPolymeshError(err: unknown): err is PolymeshError {
const error = err as PolymeshError;

return typeof error.code === 'string' && typeof error.message === 'string';
}

0 comments on commit e07bdd8

Please sign in to comment.