Merge lp:~widelands-dev/widelands/bug-986611-asserts into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7578
Proposed branch: lp:~widelands-dev/widelands/bug-986611-asserts
Merge into: lp:widelands
Diff against target: 66 lines (+16/-5)
3 files modified
src/economy/routeastar.cc (+4/-1)
src/io/filesystem/zip_filesystem.cc (+9/-3)
src/network/internet_gaming.cc (+3/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-986611-asserts
Reviewer Review Type Date Requested Status
TiborB Approve
Review via email: mp+275642@code.launchpad.net

Description of the change

Replaced some assert statements with exceptions.

To post a comment you must log in.
Revision history for this message
TiborB (tiborb95) wrote :

nothing can be wrong here :)

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for all the reviews :)

Well, I could have my ! wrong :P

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/economy/routeastar.cc'
2--- src/economy/routeastar.cc 2013-07-26 20:19:36 +0000
3+++ src/economy/routeastar.cc 2015-10-25 15:47:27 +0000
4@@ -19,6 +19,7 @@
5
6 #include "economy/routeastar.h"
7
8+#include "base/wexception.h"
9 #include "economy/iroute.h"
10 #include "economy/router.h"
11
12@@ -37,7 +38,9 @@
13 */
14 void BaseRouteAStar::routeto(RoutingNode & to, IRoute & route)
15 {
16- assert(!to.cookie().is_active());
17+ if (to.cookie().is_active()) {
18+ throw wexception("BaseRouteAStar::routeto should not have an active cookie.");
19+ }
20 assert(to.mpf_cycle == mpf_cycle);
21
22 route.init(to.mpf_realcost);
23
24=== modified file 'src/io/filesystem/zip_filesystem.cc'
25--- src/io/filesystem/zip_filesystem.cc 2014-10-27 10:14:10 +0000
26+++ src/io/filesystem/zip_filesystem.cc 2015-10-25 15:47:27 +0000
27@@ -182,8 +182,12 @@
28 FileSystem * ZipFilesystem::make_sub_file_system(const std::string & path) {
29 m_open_unzip();
30
31- assert(file_exists(path));
32- assert(is_directory(path));
33+ if (!file_exists(path)) {
34+ throw wexception("ZipFilesystem::make_sub_file_system: The path does not exist.");
35+ }
36+ if (!is_directory(path)) {
37+ throw wexception("ZipFilesystem::make_sub_file_system: The path needs to be a directory.");
38+ }
39
40 m_close();
41
42@@ -206,7 +210,9 @@
43 // see Filesystem::create
44 FileSystem * ZipFilesystem::create_sub_file_system(const std::string & path, Type const type)
45 {
46- assert(!file_exists(path));
47+ if (file_exists(path)) {
48+ throw wexception("ZipFilesystem::create_sub_file_system: Sub file system already exists.");
49+ }
50
51 if (type != FileSystem::DIR)
52 throw ZipOperationError
53
54=== modified file 'src/network/internet_gaming.cc'
55--- src/network/internet_gaming.cc 2015-07-30 07:16:09 +0000
56+++ src/network/internet_gaming.cc 2015-10-25 15:47:27 +0000
57@@ -184,7 +184,9 @@
58 /// Relogin to metaserver after loosing connection
59 bool InternetGaming::relogin()
60 {
61- assert(error());
62+ if (!error()) {
63+ throw wexception("InternetGaming::relogin: This only makes sense if there was an error.");
64+ }
65
66 initialize_connection();
67

Subscribers

People subscribed via source and target branches

to status/vote changes: