mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
* exchanges/account: shift credentials to account package and segregate funds to keys * merge: fixes * linter: fix * Update exchanges/account/account.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * glorious: nits + protection for string panic * glorious_suggestion: add method for matching keys * linter: fix tests * account: add protected method for credentials minimizing access, display full account details to rpc. * linter: spelling kweeeeeeen * accounts/portfolio: clean/check portfolio code and quickly check balances from change. Add protected method for future matching. * accounts: theres no point in pointerising everything * linter: ok pointerise this then... * exchanges: fix regression add in little notes. * glorious: nits * Update exchanges/account/credentials.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update exchanges/account/credentials_test.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update exchanges/account/credentials_test.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * glorious: nits * gloriously: fix glorious glorious test gloriously * script: initial implementation of error insertion on return * script: make script context aware(ish) and update error handle in examples * script: add tests * script: add syntax highlighting to readme * Update gctscript/vm/vm.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/vm/vm.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/examples/exchange/account_info.gct Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/examples/exchange/cancel_order.gct Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/examples/verbose.gct Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/modules/gct/gct_test.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * glorious: nits * rm: bros * scripts: handle errors in examples when they are going to use the data after fetching * linter: fix rides again * SCOTT_SPELL_CHECK_LINTER: fix * gctscript: fix tests * glorious: niiiiiiiiiiiiits * scriptmodules/gct: standardize runtime errors * Update gctscript/modules/gct/exchange.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/modules/gct/exchange.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/modules/gct/exchange.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/modules/gct/exchange.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/modules/gct/gct.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/modules/gct/gct.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/modules/gct/gct.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/modules/gct/gct.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/modules/gct/gct.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/modules/gct/gct.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update gctscript/modules/gct/gct.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * glorious: nits/reverts * go mod: tidy Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package gct
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
objects "github.com/d5/tengo/v2"
|
|
"github.com/thrasher-corp/gocryptotrader/common"
|
|
)
|
|
|
|
const standardFormatting = "%s"
|
|
|
|
var (
|
|
errFormatStringIsEmpty = errors.New("format string is empty")
|
|
errNoArguments = errors.New("no arguments for error response")
|
|
)
|
|
|
|
// errorResponsef is a helper function to apply error details to a return object
|
|
// for better script side error handling
|
|
func errorResponsef(format string, a ...interface{}) (objects.Object, error) {
|
|
if format == "" {
|
|
return nil, fmt.Errorf("cannot generate tengo error object %w", errFormatStringIsEmpty)
|
|
}
|
|
|
|
if len(a) == 0 {
|
|
return nil, fmt.Errorf("cannot generate tengo error object %w", errNoArguments)
|
|
}
|
|
|
|
return &objects.Error{
|
|
Value: &objects.String{Value: fmt.Sprintf(format, a...)},
|
|
}, nil
|
|
}
|
|
|
|
func constructRuntimeError(argPosition int, funcName, expectedType string, unexpectedData interface{}) error {
|
|
return fmt.Errorf("function [%s] argument position [%d] - %w",
|
|
funcName,
|
|
argPosition,
|
|
common.GetAssertError(expectedType, unexpectedData))
|
|
}
|