static inline ExtendedException create( ExceptionCodeType<ExtendedException::ec_not_implemented> code, const std::string &description, const char* file, const char* function, unsigned int line) { return ExtendedException(code.number, description, "not_implemented", file, function, line); }
static inline ExtendedException create( ExceptionCodeType<ExtendedException::ec_internal_error> code, const std::string &description, const char* file, const char* function, unsigned int line) { return ExtendedException(code.number, description, "internal_error", file, function, line); }
static inline ExtendedException create( ExceptionCodeType<ExtendedException::ec_duplicate_item> code, const std::string &description, const char* file, const char* function, unsigned int line) { return ExtendedException(code.number, description, "duplicate_item", file, function, line); }
// assert_impl already defined in util/assertions.h static Variant impl_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()); } String name(message.isNull() ? "Assertion" : message.toString()); if (s_option_data->assertWarning) { auto const str = !assertion.isString() ? " failed" : concat3(" \"", assertion.toString(), "\" failed"); raise_warning("%s%s", name.data(), str.data()); } if (s_option_data->assertBail) { throw ExtendedException("An assertion was raised."); } return init_null(); }
void throw_invalid_object_type(const char* clsName) { throw ExtendedException("Unexpected object type %s.", clsName); }
void throw_null_pointer_exception() { throw ExtendedException("A null object pointer was used."); }
void throw_not_supported(const char* feature, const char* reason) { throw ExtendedException("%s is not supported: %s", feature, reason); }
void throw_not_implemented(const char* feature) { throw ExtendedException("%s is not implemented yet.", feature); }