Molybden API
Loading...
Searching...
No Matches
molybden::JsReturnValue Class Reference

Represents the JS function return value. More...

#include <js_return_value.hpp>

Public Member Functions

 JsReturnValue (JsValue &&value)
 
 JsReturnValue (JsError &&error)
 
 JsReturnValue (JsReturnValue &&other)
 
void operator= (JsReturnValue &&other)
 
bool isCorrect () const
 Indicates if the execution finished successfully and returned a value.
 
JsValue asValue () &&
 Returns the value that the return value represents if it does, otherwise it should not be called.
 
JsError asError () &&
 Returns the error that the return value represents if it does, otherwise it should not be called.
 
 operator bool () const
 Returns the result of isCorrect().
 

Detailed Description

Represents the JS function return value.

To unwrap the return value, check whether it is an error or the actual value, and then use std::move:

JsReturnValue result = object->call("method");
if (result) {
JsValue value = std::move(result).asValue();
...
}
Represents the JS function return value.
Definition js_return_value.hpp:35
A JavaScript value.
Definition js_value.hpp:44

The JS function can either return value or throw an exception and this class represents these two possibilities.

Member Function Documentation

◆ isCorrect()

bool molybden::JsReturnValue::isCorrect ( ) const

Indicates if the execution finished successfully and returned a value.

Use this method to determine whether to unwrap the object as a value or as an error.


The documentation for this class was generated from the following file: