How to do error handling in Vagrant file

134 views
Skip to first unread message

Rohit Singh

unread,
Dec 7, 2015, 8:14:41 AM12/7/15
to Vagrant
Hi All,

I am trying to do error handling in vagrant file. 

My use case :
1. Bring up  VMs on openstack. (Using Vagrant openstack plugin)
2. Bring up  VMs on Virtual box.

Bringing up VM's happened smoothly. If i have to handle some error scenarios like,  resource stack on openstack or virtual box throwing some errors.

Is it possible ?

I have tried using begin rescue blocks. following was observed
1.  In case of any exceptions control didnot go to rescue blocks. 
2.  Is there any status code or message which can be interpreted in Vagrant file and some proper error message or handling can be done.
3.  If  manually syntax error is induced then control comes in rescue block

begin

config.vm.provider "openstack" do |os, override|
end  
rescue

## some handling or raising custom exception
end


Please correct me if my approach is wrong and do suggest any other ways to handle the error  scenarios.

Thanks
Rohit 



Reply all
Reply to author
Forward
0 new messages