Repository navigation
Replace catch with try-catch to fix the compilation error in OTP-29 - #187
Open
jiahuili430 wants to merge 2 commits into
Open
jiahuili430 wants to merge 2 commits into
jiahuili430 wants to merge 2 commits into
Conversation
- Add `OTP-29` to GitHub Actions to run tests. - Update actions/checkout from `v5` to `v6`.
jiahuili430
force-pushed
the
replace-catch-to-try-catch
branch
from
May 23, 2026 21:20
07ad5f1 to
ff5d372
Compare
Comment on lines
+1062
to
+1064
| throw:Term -> Term; | ||
| exit:Reason -> {'EXIT', Reason}; | ||
| error:Reason:Stacktrace -> {'EXIT', {Reason, Stacktrace}} |
Owner
There was a problem hiding this comment.
Suggested change
| throw:Term -> Term; | |
| exit:Reason -> {'EXIT', Reason}; | |
| error:Reason:Stacktrace -> {'EXIT', {Reason, Stacktrace}} | |
| _:_ -> | |
| ok |
Contributor
Author
There was a problem hiding this comment.
Thank you for the review!
Updated to use the ?TRY_CATCH() macro to slightly simplify the code.
catch can handle throw, but not exit or error. If modify them to _:_ -> ok,
the behavior of the function will be changed.
1> catch(ok).
ok
2> catch(throw(throw_error)).
throw_error
3> catch(exit(timeout)).
{'EXIT',timeout}
4> catch(exit({timeout, reason})).
{'EXIT',{timeout,reason}}
5> catch(error({noproc, reason})).
{'EXIT',{{noproc,reason},
[{shell,apply_fun,3,[{file,"shell.erl"},{line,1209}]},
{erl_eval,do_apply,7,[{file,"erl_eval.erl"},{line,1048}]},
{erl_eval,expr,6,[{file,"erl_eval.erl"},{line,780}]},
{shell,exprs,7,[{file,"shell.erl"},{line,970}]},
{shell,eval_exprs,7,[{file,"shell.erl"},{line,926}]},
{shell,eval_loop,4,[{file,"shell.erl"},{line,911}]}]}}Also, documentation mentioned this, see https://www.erlang.org/doc/system/expressions.html#try
Next is an example of using try to emulate catch Expr:
try Expr catch throw:Term -> Term; exit:Reason -> {'EXIT',Reason}; error:Reason:Stk -> {'EXIT',{Reason,Stk}} end
Fix the following compilation errors: ```bash $ make src/ibrowse_lib.erl:65:10: 'catch ...' is deprecated; please use 'try ... catch ... end' instead. Compile directive 'nowarn_deprecated_catch' can be used to suppress warnings in selected modules. % 65| case catch decode_rfc822_date_1(string:tokens(String, ", \t\r\n")) of % | ```
jiahuili430
force-pushed
the
replace-catch-to-try-catch
branch
from
May 23, 2026 22:59
ff5d372 to
817fed6
Compare
nickva
added a commit
to nickva/ibrowse
that referenced
this pull request
Jun 7, 2026
In OTP 29 catch statements started to throw deprecation warnings, and since we're using `warnings_as_errors` our compilation fails. The catch construct hasn't been scheduled for removal yet [1] so for now just to compile ibrowse add a per-module compiler directive. This allows catch rewrites to be done incrementally module-by-module eventually. This is an intermediate alternative for cmullaparthi#187 for now. [1] https://www.erlang.org/doc/scheduled_for_removal.html
Open
|
@cmullaparthi This would be nice to get into the main branch in combination with #189 and #190 😃. |
2 tasks done
nickva
added a commit
to nickva/ibrowse
that referenced
this pull request
Jun 13, 2026
In OTP 29 catch statements started to throw deprecation warnings, and since we're using `warnings_as_errors` our compilation fails. The catch construct hasn't been scheduled for removal yet [1] so for now just to compile ibrowse add a per-module compiler directive. This allows catch rewrites to be done incrementally module-by-module eventually. This is an intermediate alternative for cmullaparthi#187 for now. [1] https://www.erlang.org/doc/scheduled_for_removal.html
nickva
added a commit
to apache/couchdb-ibrowse
that referenced
this pull request
Jun 13, 2026
In OTP 29 catch statements started to throw deprecation warnings, and since we're using `warnings_as_errors` our compilation fails. The catch construct hasn't been scheduled for removal yet [1] so for now just to compile ibrowse add a per-module compiler directive. This allows catch rewrites to be done incrementally module-by-module eventually. This is an intermediate alternative for cmullaparthi/ibrowse#187 for now. [1] https://www.erlang.org/doc/scheduled_for_removal.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI:
OTP-29to GitHub Actions to run tests.v5tov6.Replace
catchwithtry-catchto fix the compilation error in OTP-29: