OR-Tools  9.6
status.cc
Go to the documentation of this file.
1 // Copyright 2010-2022 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 #include "ortools/glop/status.h"
15 
16 #include <string>
17 #include <utility>
18 
19 #include "ortools/base/logging.h"
20 
21 namespace operations_research {
22 namespace glop {
23 
24 Status::Status() : error_code_(GLOP_OK), error_message_() {}
25 
26 Status::Status(ErrorCode error_code, std::string error_message)
27  : error_code_(error_code),
28  error_message_(error_code == GLOP_OK ? "" : std::move(error_message)) {}
29 
30 std::string GetErrorCodeString(Status::ErrorCode error_code) {
31  switch (error_code) {
32  case Status::GLOP_OK:
33  return "GLOP_OK";
34  case Status::ERROR_LU:
35  return "ERROR_LU";
37  return "ERROR_BOUND";
38  case Status::ERROR_NULL:
39  return "ERROR_NULL";
41  return "INVALID_PROBLEM";
42  }
43  // Fallback. We don't use "default:" so the compiler will return an error
44  // if we forgot one enum case above.
45  LOG(DFATAL) << "Invalid Status::ErrorCode " << error_code;
46  return "UNKNOWN Status::ErrorCode";
47 }
48 
49 } // namespace glop
50 } // namespace operations_research
std::string GetErrorCodeString(Status::ErrorCode error_code)
Definition: status.cc:30
Collection of objects used to extend the Constraint Solver library.