How to use the @0x/utils.errorUtils.spawnSwitchErr function in @0x/utils

To help you get started, we’ve selected a few @0x/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xProject / 0x-monorepo / packages / website / ts / components / token_balances.tsx View on Github external
case BalanceErrs.MintingFailed:
                return <div>Minting your test tokens failed unexpectedly. Please refresh the page and try again.</div>;

            case BalanceErrs.AllowanceSettingFailed:
                return (
                    <div>
                        An unexpected error occurred while trying to set your test token allowance. Please refresh the
                        page and try again.
                    </div>
                );

            case undefined:
                return null; // No error to show

            default:
                throw errorUtils.spawnSwitchErr('errorType', this.state.errorType);
        }
    }
    private _onErrorOccurred(errorType: BalanceErrs): void {
github 0xProject / 0x-monorepo / packages / react-docs / src / components / type.tsx View on Github external
/&gt;
                );
            });
            typeName = (
                <div>
                    [
                    {_.reduce(tupleTypes, (prev: React.ReactNode, curr: React.ReactNode) =&gt; {
                        return [prev, ', ', curr];
                    })}
                    ]
                </div>
            );
            break;

        default:
            throw errorUtils.spawnSwitchErr('type.typeDocType', type.typeDocType);
    }
    // HACK: Normalize BigNumber to simply BigNumber. For some reason the type
    // name is unpredictably one or the other.
    if (typeName === 'BigNumber') {
        typeName = 'BigNumber';
    }
    const commaSeparatedTypeArgs = _.reduce(typeArgs, (prev: React.ReactNode, curr: React.ReactNode) =&gt; {
        return [prev, ', ', curr];
    });

    const isExportedClassReference = !!props.type.isExportedClassReference;
    const typeNameUrlIfExists = !_.isUndefined(props.type.externalLink) ? props.type.externalLink : undefined;
    if (!_.isUndefined(typeNameUrlIfExists)) {
        typeName = props.isInPopover ? (
            <span style="{{">{typeName}</span>
        ) : (
github 0xProject / 0x-monorepo / packages / order-watcher / src / order_watcher / order_watcher.ts View on Github external
}
                break;
            }
            case ExchangeEvents.CancelUpTo: {
                // TODO(logvinov): Do it smarter and actually look at the salt and order epoch
                // Invalidate cache
                const args = decodedLog.args as ExchangeCancelUpToEventArgs;
                this._orderFilledCancelledLazyStore.deleteAllIsCancelled();
                // Revalidate orders
                const orderHashes = this._dependentOrderHashesTracker.getDependentOrderHashesByMaker(args.makerAddress);
                await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
                break;
            }

            default:
                throw errorUtils.spawnSwitchErr('decodedLog.event', decodedLog.event);
        }
    }
    private async _emitRevalidateOrdersAsync(orderHashes: string[], transactionHash?: string): Promise {
github 0xProject / 0x-monorepo / packages / website / ts / utils / typedoc_utils.ts View on Github external
const seenTypeNames = _.map(docSection.types, t => t.name);
                    const isUnseen = !_.includes(seenTypeNames, customType.name);
                    if (isUnseen) {
                        docSection.types.push(customType);
                    }
                    break;
                }

                case KindString.Class:
                    // We currently do not support more then a single class per file
                    // except for the types section, where we ignore classes since we
                    // only want to render type definitions.
                    break;

                default:
                    throw errorUtils.spawnSwitchErr('kindString', entity.kindString);
            }
        });
        return docSection;
github 0xProject / 0x-monorepo / packages / website / ts / components / wallet / wallet.tsx View on Github external
let buttonIconName;
        if (isWrappedEtherDirectionOpen) {
            buttonLabel = 'cancel';
            buttonIconName = 'zmdi-close';
        } else {
            switch (wrappedEtherDirection) {
                case Side.Deposit:
                    buttonLabel = 'wrap';
                    buttonIconName = 'zmdi-long-arrow-down';
                    break;
                case Side.Receive:
                    buttonLabel = 'unwrap';
                    buttonIconName = 'zmdi-long-arrow-up';
                    break;
                default:
                    throw errorUtils.spawnSwitchErr('wrappedEtherDirection', wrappedEtherDirection);
            }
        }
        const onClick = isWrappedEtherDirectionOpen
            ? this._closeWrappedEtherActionRow.bind(this, wrappedEtherDirection)
            : this._openWrappedEtherActionRow.bind(this, wrappedEtherDirection);
        return (
            
        );
    }
    private _openWrappedEtherActionRow(wrappedEtherDirection: Side): void {
github 0xProject / 0x-monorepo / packages / website / ts / components / ui / lifecycle_raised_button.tsx View on Github external
return <span>;
        }

        let label;
        switch (this.state.buttonState) {
            case ButtonState.Ready:
                label = this.props.labelReady;
                break;
            case ButtonState.Loading:
                label = this.props.labelLoading;
                break;
            case ButtonState.Complete:
                label = this.props.labelComplete;
                break;
            default:
                throw errorUtils.spawnSwitchErr('ButtonState', this.state.buttonState);
        }
        return (
            
        );
    }
    public async onClickAsync(): Promise {</span>