Preventing error wehen message is an object

This method throwed "TypeError: Object #<Object> has no method 'substr'" when the message was an object.