Add optional options handling in objectCall.run method
- Modify options unmarshaling to handle undefined JavaScript options - Add null check to prevent unmarshaling errors when no options are provided - Improve robustness of method call argument processing
This commit is contained in:
parent
48d65c0e39
commit
709c7ec738
1 changed files with 6 additions and 3 deletions
|
|
@ -202,9 +202,12 @@ func (obj *objectCall) run(info *v8go.FunctionCallbackInfo) *v8go.Value {
|
|||
return bridge.JsException(info.Context(), fmt.Sprintf("Failed to get the options: %s", err.Error()))
|
||||
}
|
||||
|
||||
err = bridge.Unmarshal(jsOptions, &options)
|
||||
if err != nil {
|
||||
return bridge.JsException(info.Context(), fmt.Sprintf("Failed to unmarshal the options: %s", err.Error()))
|
||||
// Check if the options is undefined
|
||||
if !jsOptions.IsUndefined() {
|
||||
err = bridge.Unmarshal(jsOptions, &options)
|
||||
if err != nil {
|
||||
return bridge.JsException(info.Context(), fmt.Sprintf("Failed to unmarshal the options: %s", err.Error()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue