Esempio n. 1
0
[[noreturn]]
static void mcr_throwOptionException(
  const std::vector<mc::McrouterOptionError>& errors) {
  if (!c_MCRouterOptionException) {
    c_MCRouterOptionException =
      Unit::lookupClass(s_MCRouterOptionException.get());
    assert(c_MCRouterOptionException);
  }

  Array errorArray = Array::Create();
  for (auto err : errors) {
    Array e;
    e.set(s_option, String(err.requestedName));
    e.set(s_value, String(err.requestedValue));
    e.set(s_error, String(err.errorMsg));
    errorArray.append(e);
  }

  Object obj{c_MCRouterOptionException};
  TypedValue ret;
  g_context->invokeFunc(
    &ret,
    c_MCRouterOptionException->getCtor(),
    make_packed_array(errorArray),
    obj.get());
  throw_object(obj);
}
Esempio n. 2
0
void throwSoapFaultObject(const Variant& code,
                          const Variant& message,
                          const Variant& actor /* = uninit_variant */,
                          const Variant& detail /* = uninit_variant */,
                          const Variant& name /* = uninit_variant */,
                          const Variant& header /* = uninit_variant */) {
  throw_object(Object{AllocSoapFaultObject(code, message,
                                    actor, detail,
                                    name, header)});
}
Esempio n. 3
0
static Variant HHVM_FUNCTION(assert, const Variant& assertion,
                             const Variant& message /* = null */) {
  if (!s_option_data->assertActive) return true;

  CallerFrame cf;
  Offset callerOffset;
  auto const fp = cf(&callerOffset);

  auto const passed = [&]() -> bool {
    if (assertion.isString()) {
      if (RuntimeOption::EvalAuthoritativeMode) {
        // We could support this with compile-time string literals,
        // but it's not yet implemented.
        throw_not_supported("assert()",
          "assert with strings argument in RepoAuthoritative mode");
      }
      return eval_for_assert(fp, assertion.toString()).toBoolean();
    }
    return assertion.toBoolean();
  }();
  if (passed) return true;

  if (!s_option_data->assertCallback.isNull()) {
    auto const unit = fp->m_func->unit();

    PackedArrayInit ai(3);
    ai.append(String(const_cast<StringData*>(unit->filepath())));
    ai.append(Variant(unit->getLineNumber(callerOffset)));
    ai.append(assertion.isString() ? assertion : empty_string_variant_ref);
    HHVM_FN(call_user_func)(s_option_data->assertCallback, ai.toArray());
  }
  if (s_option_data->assertException) {
    if (message.isObject()) {
      Object exn = message.toObject();
      if (exn.instanceof(SystemLib::s_AssertionErrorClass)) {
        throw_object(exn);
      }
    }

    SystemLib::throwExceptionObject(message.toString());
  }
  if (s_option_data->assertWarning) {
    String name(message.isNull() ? "Assertion" : message.toString());
    auto const str = !assertion.isString()
      ? " failed"
      : concat3(" \"",  assertion.toString(), "\" failed");
    raise_warning("assert(): %s%s", name.data(),  str.data());
  }
  if (s_option_data->assertBail) {
    throw ExitException(1);
  }

  return init_null();
}
Esempio n. 4
0
[[noreturn]]
static void mcr_throwException(const std::string& message,
                               mc_op_t op = mc_op_unknown,
                               mc_res_t reply = mc_res_unknown,
                               const std::string& key = "") {
  if (!c_MCRouterException) {
    c_MCRouterException = Unit::lookupClass(s_MCRouterException.get());
    assert(c_MCRouterException);
  }

  Object obj{c_MCRouterException};
  TypedValue ret;
  g_context->invokeFunc(
    &ret,
    c_MCRouterException->getCtor(),
    make_packed_array(message, (int64_t)op, (int64_t)reply, key),
    obj.get());
  tvRefcountedDecRef(&ret);
  throw_object(obj);
}
Esempio n. 5
0
void thrift_error(const String& what, TError why) {
  throw_object(s_TProtocolException, make_packed_array(what, why));
}
Esempio n. 6
0
void throwInvalidOperationExceptionObject(const Variant& message) {
  throw_object(AllocInvalidOperationExceptionObject(message));
}
Esempio n. 7
0
void throwDOMExceptionObject(const Variant& message,
                             const Variant& code) {
  throw_object(AllocDOMExceptionObject(message, code));
}
Esempio n. 8
0
void throwRuntimeExceptionObject(const Variant& message) {
  throw_object(AllocRuntimeExceptionObject(message));
}
Esempio n. 9
0
void throwOutOfBoundsExceptionObject(const Variant& message) {
  throw_object(AllocOutOfBoundsExceptionObject(message));
}
Esempio n. 10
0
void throwBadMethodCallExceptionObject(const Variant& message) {
  throw_object(AllocBadMethodCallExceptionObject(message));
}
Esempio n. 11
0
void throwInvalidArgumentExceptionObject(const Variant& message) {
  throw_object(AllocInvalidArgumentExceptionObject(message));
}
Esempio n. 12
0
void throwTypeErrorObject(const Variant& message) {
  throw_object(AllocTypeErrorObject(message));
}
Esempio n. 13
0
void throwParseErrorObject(const Variant& message) {
  throw_object(AllocParseErrorObject(message));
}
Esempio n. 14
0
void throwDivisionByZeroErrorObject(const Variant& message) {
  throw_object(AllocDivisionByZeroErrorObject(message));
}
Esempio n. 15
0
void throwArithmeticErrorObject(const Variant& message) {
  throw_object(AllocArithmeticErrorObject(message));
}
Esempio n. 16
0
void throwExceptionObject(const Variant& message) {
  throw_object(AllocExceptionObject(message));
}