Unverified Commit 37ce3eb2 authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

replace std::runtime_error with Log::Fatal (#2816)

* replace std::runtime_error with Log::Fatal

* Update c_api.cpp
parent 73dc1bbd
......@@ -81,7 +81,7 @@ PredictionEarlyStopInstance CreatePredictionEarlyStopInstance(const std::string&
} else if (type == "binary") {
return CreateBinary(config);
} else {
throw std::runtime_error("Unknown early stopping type: " + type);
Log::Fatal("Unknown early stopping type: %s", type.c_str());
}
}
......
......@@ -1130,7 +1130,7 @@ int LGBM_DatasetSetField(DatasetHandle handle,
} else if (type == C_API_DTYPE_FLOAT64) {
is_success = dataset->SetDoubleField(field_name, reinterpret_cast<const double*>(field_data), static_cast<int32_t>(num_element));
}
if (!is_success) { throw std::runtime_error("Input data type error or field not found"); }
if (!is_success) { Log::Fatal("Input data type error or field not found"); }
API_END();
}
......@@ -1152,7 +1152,7 @@ int LGBM_DatasetGetField(DatasetHandle handle,
*out_type = C_API_DTYPE_FLOAT64;
is_success = true;
}
if (!is_success) { throw std::runtime_error("Field not found"); }
if (!is_success) { Log::Fatal("Field not found"); }
if (*out_ptr == nullptr) { *out_len = 0; }
API_END();
}
......@@ -1802,7 +1802,7 @@ RowFunctionFromDenseMatric(const void* data, int num_row, int num_col, int data_
};
}
}
throw std::runtime_error("Unknown data type in RowFunctionFromDenseMatric");
Log::Fatal("Unknown data type in RowFunctionFromDenseMatric");
}
std::function<std::vector<std::pair<int, double>>(int row_idx)>
......@@ -1906,7 +1906,7 @@ RowFunctionFromCSR(const void* indptr, int indptr_type, const int32_t* indices,
};
}
}
throw std::runtime_error("Unknown data type in RowFunctionFromCSR");
Log::Fatal("Unknown data type in RowFunctionFromCSR");
}
std::function<std::pair<int, double>(int idx)>
......@@ -1971,7 +1971,7 @@ IterateFunctionFromCSC(const void* col_ptr, int col_ptr_type, const int32_t* ind
};
}
}
throw std::runtime_error("Unknown data type in CSC matrix");
Log::Fatal("Unknown data type in CSC matrix");
}
CSC_RowIterator::CSC_RowIterator(const void* col_ptr, int col_ptr_type, const int32_t* indices,
......
......@@ -1487,7 +1487,7 @@ void PushClearIfEmpty(std::vector<T>* dest, const size_t dest_len,
void Dataset::AddFeaturesFrom(Dataset* other) {
if (other->num_data_ != num_data_) {
throw std::runtime_error(
Log::Fatal(
"Cannot add features from other Dataset with a different number of "
"rows");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment