Repository: jerryscript-project/jerryscript
File: jerry-core/api/jerry.c (C)

Code before:
  JERRY_UNUSED (symbol);

  return ECMA_VALUE_UNDEFINED;
#endif /* ENABLED (JERRY_ESNEXT) */
} /** jerry_get_well_known_symbol */

/**
 * Returns the description internal property of a symbol.
 *
 * Note:
 *      returned value must be freed with jerry_release_value, when it is no longer needed.
 *
 * @return string or undefined value containing the symbol's description - if success
 *         thrown error - otherwise
 */
jerry_value_t
jerry_get_symbol_description (const jerry_value_t symbol) /**< symbol value */
{
  jerry_assert_api_available ();

#if ENABLED (JERRY_ESNEXT)
  if (!ecma_is_value_symbol (symbol))
  {
    return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (wrong_args_msg_p)));
  }

  /* Note: This operation cannot throw an error */
  return ecma_get_symbol_description (ecma_get_symbol_from_value (symbol));
#else /* !ENABLED (JERRY_ESNEXT) */
  JERRY_UNUSED (symbol);

  return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Symbol is not supported.")));
#endif /* ENABLED (JERRY_ESNEXT) */
} /* jerry_get_symbol_description */

/**
 * Call the SymbolDescriptiveString ecma builtin operation on the symbol value.
 *
 * Note:
 *      returned value must be freed with jerry_release_value, when it is no longer needed.
 *
 * @return string value containing the symbol's descriptive string - if success
 *         thrown error - otherwise
 */
jerry_value_t
jerry_get_symbol_descriptive_string (const jerry_value_t symbol) /**< symbol value */
{
  jerry_assert_api_available ();

#if ENABLED (JERRY_ESNEXT)
  if (!ecma_is_value_symbol (symbol))

Review comment (suggestion):
Please change the return value of this function to `jerry_value_t` which returns:
 - thrown error - if any conversion error happens
 - ECMA_VALUE_TRUE - otherwise.

Code after:
 */
jerry_value_t
jerry_from_property_descriptor (const jerry_property_descriptor_t *src_prop_desc_p) /**< property descriptor */
{
  jerry_assert_api_available ();

  ecma_property_descriptor_t prop_desc = jerry_property_descriptor_to_ecma (src_prop_desc_p);

  if (ECMA_IS_VALUE_ERROR (prop_desc.value))
  {
    return jerry_throw (prop_desc.value);
  }

  ecma_object_t *desc_obj_p = ecma_op_from_property_descriptor (&prop_desc);

  return ecma_make_object_value (desc_obj_p);
} /* jerry_from_property_descriptor */

/**
* ToPropertyDescriptor abstract operation.
*
* @return thrown error - if any conversion error happens
*        ECMA_VALUE_TRUE - otherwise.
*/
bool
jerry_to_property_descriptor (jerry_value_t obj_value, /**< object value */
                             jerry_property_descriptor_t *out_prop_desc_p) /**< [out] filled property descriptor
                                                                               if return value is normal
                                                                               empty completion value */
{
  jerry_assert_api_available ();

  if (!ecma_is_value_object (obj_value))
  {
    jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (wrong_args_msg_p)));
  }

  ecma_property_descriptor_t prop_desc;
  jerry_value_t result = ecma_op_to_property_descriptor (obj_value, &prop_desc);

  if (ECMA_IS_VALUE_ERROR (result))
  {
    return false;
  }
  *out_prop_desc_p = jerry_property_descriptor_from_ecma (&prop_desc);

  if (ECMA_IS_VALUE_ERROR (out_prop_desc_p->value))
  {
    jerry_release_value (result);
    return false;
  }