example with error and onclose handling