Fastlane: Handle errors individually?

Created on 29 Aug 2016  路  3Comments  路  Source: fastlane/fastlane

Hi,
is there a way to catch errors and analyse them without breaking the whole process?

We have multiple apps/targets that need to be built and uploaded to iTunesConnect. Sometimes one upload fails, because i.e. some metadata is not correct on iTunesConnect.
The process will fail completely and this is expected.
But if we will run the process again, it may fail because some apps/targets are already uploaded to iTunesConnect with the same version. This will be an error stopping the process again. In this special case, this is ok. Just print this kind of error and continue the build process would be my expected behaviour.

But I found no way to check if 'deliver' raised such an error. Can you give me a hint to solve this issue?

Thanks in advance :)

Most helpful comment

Thanks a lot, this is what I was looking for. I had the Ruby exception handling but I missed how to pass the exception to the rescue block. 馃槈

All 3 comments

Hi @StephanPartzsch - good question! Are you using a Fastfile?

If so, one way you can manage this with a bit of Ruby exception handling.

lane :app_store do
  # Actions which must succeed...
  match
  gym

  begin
    # Something where you'd like to be able to react to failures
    deliver
  # If ANY exception happens, let me handle it
  rescue => ex
    # re-raise the exception unless it's something we're OK with ignoring
    raise ex unless ex.message.include?('Error message of interest')
    UI.important('deliver failed, but continuing anyway!')
  end

  # More things which must succeed
  slack
end

Let me know if that gets you going on your desired behavior! 馃憤

Using the standard Ruby exception handling @mfurtak mentioned is the best and cleanest way to do so 馃憤

Thanks a lot, this is what I was looking for. I had the Ruby exception handling but I missed how to pass the exception to the rescue block. 馃槈

Was this page helpful?
0 / 5 - 0 ratings