Skip to content

Commit 31acf26

Browse files
committed
Better error messages
1 parent 53bde5c commit 31acf26

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ feel free to submit either an issue or pull request through github if you want
2525
to fix something or suggest a needed improvment, even if it's just to add an
2626
extra sentence in this README.
2727

28-
Once the package gets tested somewhat in the wild, I'll plan to move it
29-
directly to version 1.0.
28+
#### Testing
29+
30+
Currently, `Pkg.test("RobotOS")` requires some bootstrapping to work properly.
31+
Before running Julia, make sure a ROS master is running and start the helper
32+
node by running the `test/echonode.py` file.
3033

3134
## Usage: Type Generation
3235

src/gentypes.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ abstract MsgT
6363
abstract SrvT
6464
abstract ServiceDefinition
6565

66-
#Rearranges the expression into a RobotOS._usepkg call. Input comes in as a
66+
#Rearranges the expression into a RobotOS._rosimport call. Input comes in as a
6767
#single package qualified expression, or as a tuple expression where the first
6868
#element is the same as the single expression case. Most of the code is just
6969
#error checking that the input takes that form.
@@ -79,10 +79,10 @@ macro rosimport(input)
7979
@assert isa(t, Symbol) "Type name ($(string(t))) not a symbol"
8080
push!(types, string(t))
8181
end
82-
return :(_usepkg($pkg, $ismsg, $types...))
82+
return :(_rosimport($pkg, $ismsg, $types...))
8383
else
8484
pkg, ismsg, typ = _pkgtype_import(input)
85-
return :(_usepkg($pkg, $ismsg, $typ))
85+
return :(_rosimport($pkg, $ismsg, $typ))
8686
end
8787
end
8888

@@ -110,10 +110,10 @@ function _pkgtype_import(input::Expr)
110110
return ps,msb,ts
111111
end
112112
#Import a set of types from a single package
113-
function _usepkg(package::ASCIIString, ismsg::Bool, names::ASCIIString...)
113+
function _rosimport(package::ASCIIString, ismsg::Bool, names::ASCIIString...)
114114
global _rospy_imports
115115
if ! haskey(_rospy_imports, package)
116-
@debug("Creating new package: ",package,".", ismsg ? "msg" : "srv")
116+
@debug("Importing new package: ",package,".", ismsg ? "msg" : "srv")
117117
_rospy_imports[package] = ROSPackage(package)
118118
end
119119
rospypkg = _rospy_imports[package]
@@ -150,6 +150,10 @@ function addtype!(mod::ROSMsgModule, typ::ASCIIString)
150150
global _rospy_objects
151151
if !(typ in mod.members)
152152
@debug("Message type import: ", _fullname(mod), ".", typ)
153+
if _nameconflicts(typ)
154+
warn("Message type '$typ' conflicts with Julia builtin, ",
155+
"will be imported as '$(_jl_safe_name(typ,"Msg"))'")
156+
end
153157
pymod, pyobj = _pyvars(_fullname(mod), typ)
154158

155159
deptypes = pyobj[:_slot_types]
@@ -194,7 +198,8 @@ function _pyvars(modname::ASCIIString, typ::ASCIIString)
194198
try pymod[typ]
195199
catch ex
196200
isa(ex, KeyError) || rethrow(ex)
197-
throw(KeyError("'$typ' in package '$modname'"))
201+
error("Message type '$typ' not found in ROS package '$modname', ",
202+
"check the corresponding @rosimport call")
198203
end
199204
pymod, pyobj
200205
end

0 commit comments

Comments
 (0)