Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
4d033831
Commit
4d033831
authored
Mar 13, 2017
by
Guolin Ke
Browse files
not use exception in command line due to catch-miss of multi-threading exceptions.
parent
12ce2566
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
20 deletions
+19
-20
include/LightGBM/c_api.h
include/LightGBM/c_api.h
+1
-1
include/LightGBM/utils/log.h
include/LightGBM/utils/log.h
+12
-1
src/main.cpp
src/main.cpp
+2
-18
windows/LightGBM.vcxproj
windows/LightGBM.vcxproj
+1
-0
windows/LightGBM.vcxproj.filters
windows/LightGBM.vcxproj.filters
+3
-0
No files found.
include/LightGBM/c_api.h
View file @
4d033831
...
...
@@ -741,7 +741,7 @@ inline int LGBM_APIHandleException(const std::string& ex) {
return
-
1
;
}
#define API_BEGIN() try {
#define API_BEGIN()
Log::ResetUseException(true);
try {
#define API_END() } \
catch(std::exception& ex) { return LGBM_APIHandleException(ex); } \
...
...
include/LightGBM/utils/log.h
View file @
4d033831
...
...
@@ -45,6 +45,10 @@ public:
GetLevel
()
=
level
;
}
static
void
ResetUseException
(
bool
use_ex
)
{
UseException
()
=
use_ex
;
}
static
void
Debug
(
const
char
*
format
,
...)
{
va_list
val
;
va_start
(
val
,
format
);
...
...
@@ -73,7 +77,12 @@ public:
vsprintf
(
str_buf
,
format
,
val
);
#endif
va_end
(
val
);
throw
std
::
runtime_error
(
std
::
string
(
str_buf
));
if
(
UseException
())
{
throw
std
::
runtime_error
(
std
::
string
(
str_buf
));
}
else
{
fprintf
(
stderr
,
str_buf
);
exit
(
-
1
);
}
}
private:
...
...
@@ -96,6 +105,8 @@ private:
static
LogLevel
&
GetLevel
()
{
static
thread_local
LogLevel
level
=
LogLevel
::
Info
;
return
level
;
}
#endif
static
bool
&
UseException
()
{
static
bool
use_ex
=
false
;
return
use_ex
;
}
};
}
// namespace LightGBM
...
...
src/main.cpp
View file @
4d033831
...
...
@@ -2,22 +2,6 @@
#include <LightGBM/application.h>
int
main
(
int
argc
,
char
**
argv
)
{
try
{
LightGBM
::
Application
app
(
argc
,
argv
);
app
.
Run
();
}
catch
(
const
std
::
exception
&
ex
)
{
std
::
cerr
<<
"Met Exceptions:"
<<
std
::
endl
;
std
::
cerr
<<
ex
.
what
()
<<
std
::
endl
;
exit
(
-
1
);
}
catch
(
const
std
::
string
&
ex
)
{
std
::
cerr
<<
"Met Exceptions:"
<<
std
::
endl
;
std
::
cerr
<<
ex
<<
std
::
endl
;
exit
(
-
1
);
}
catch
(...)
{
std
::
cerr
<<
"Unknown Exceptions"
<<
std
::
endl
;
exit
(
-
1
);
}
LightGBM
::
Application
app
(
argc
,
argv
);
app
.
Run
();
}
windows/LightGBM.vcxproj
View file @
4d033831
...
...
@@ -206,6 +206,7 @@
<ClInclude
Include=
"..\include\LightGBM\utils\array_args.h"
/>
<ClInclude
Include=
"..\include\LightGBM\utils\common.h"
/>
<ClInclude
Include=
"..\include\LightGBM\utils\log.h"
/>
<ClInclude
Include=
"..\include\LightGBM\utils\openmp_wrapper.h"
/>
<ClInclude
Include=
"..\include\LightGBM\utils\pipeline_reader.h"
/>
<ClInclude
Include=
"..\include\LightGBM\utils\random.h"
/>
<ClInclude
Include=
"..\include\LightGBM\utils\text_reader.h"
/>
...
...
windows/LightGBM.vcxproj.filters
View file @
4d033831
...
...
@@ -177,6 +177,9 @@
<ClInclude
Include=
"..\src\io\dense_nbits_bin.hpp"
>
<Filter>
src\io
</Filter>
</ClInclude>
<ClInclude
Include=
"..\include\LightGBM\utils\openmp_wrapper.h"
>
<Filter>
include\LightGBM\utils
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"..\src\application\application.cpp"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment