Beispiel #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);
}
Beispiel #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)});
}
Beispiel #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();
}
Beispiel #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);
}
Beispiel #5
0
void thrift_error(const String& what, TError why) {
  throw_object(s_TProtocolException, make_packed_array(what, why));
}
Beispiel #6
0
void throwInvalidOperationExceptionObject(const Variant& message) {
  throw_object(AllocInvalidOperationExceptionObject(message));
}
Beispiel #7
0
void throwDOMExceptionObject(const Variant& message,
                             const Variant& code) {
  throw_object(AllocDOMExceptionObject(message, code));
}
Beispiel #8
0
void throwRuntimeExceptionObject(const Variant& message) {
  throw_object(AllocRuntimeExceptionObject(message));
}
Beispiel #9
0
void throwOutOfBoundsExceptionObject(const Variant& message) {
  throw_object(AllocOutOfBoundsExceptionObject(message));
}
Beispiel #10
0
void throwBadMethodCallExceptionObject(const Variant& message) {
  throw_object(AllocBadMethodCallExceptionObject(message));
}
Beispiel #11
0
void throwInvalidArgumentExceptionObject(const Variant& message) {
  throw_object(AllocInvalidArgumentExceptionObject(message));
}
Beispiel #12
0
void throwTypeErrorObject(const Variant& message) {
  throw_object(AllocTypeErrorObject(message));
}
Beispiel #13
0
void throwParseErrorObject(const Variant& message) {
  throw_object(AllocParseErrorObject(message));
}
Beispiel #14
0
void throwDivisionByZeroErrorObject(const Variant& message) {
  throw_object(AllocDivisionByZeroErrorObject(message));
}
Beispiel #15
0
void throwArithmeticErrorObject(const Variant& message) {
  throw_object(AllocArithmeticErrorObject(message));
}
Beispiel #16
0
void throwExceptionObject(const Variant& message) {
  throw_object(AllocExceptionObject(message));
}