fixed error handling

Use `__filename`, is this parameter really necessary?