From d99d1bbe66e2a66f2af744a104e5327633e7e5a9 Mon Sep 17 00:00:00 2001 From: Sander Spies Date: Mon, 8 Jun 2020 11:58:23 +0200 Subject: [PATCH] Improve failwith description. --- gitlab-pages/docs/reference/current.md | 44 +++-------------------- gitlab-pages/docs/reference/toplevel.md | 48 +++++++++++++++++++++---- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/gitlab-pages/docs/reference/current.md b/gitlab-pages/docs/reference/current.md index 03e617edf..81cb3d48b 100644 --- a/gitlab-pages/docs/reference/current.md +++ b/gitlab-pages/docs/reference/current.md @@ -598,53 +598,17 @@ let main = (p : unit) : address => Tezos.source; -function failwith : string -> unit +function failwith : 'a -> unit -function failwith : string -> unit +function failwith : 'a -> unit -function failwith : string -> unit +function failwith: 'a -> unit -Cause the contract to fail with an error message. +[See `failwith`](toplevel.md#failwith) -> ⚠ Using this currently requires in general a type annotation on the -> `failwith` call. - - -Note that `Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead. - - -Note that `Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead. - - - - -```pascaligo -function main (const p : int; const s : unit) : list (operation) * unit is - block { - if p > 10 then failwith ("Failure.") else skip - } - with ((nil : list (operation)), s) -``` - - - - -```cameligo -let main (p,s : int * unit) = if p > 10 then failwith "Failure." -``` - - - - -```reasonligo -let main = ((p,s) : (int, unit)) => - if (p > 10) { failwith ("Failure."); }; -``` - - function chain_id : chain_id diff --git a/gitlab-pages/docs/reference/toplevel.md b/gitlab-pages/docs/reference/toplevel.md index b1b4e7b3c..4858d5598 100644 --- a/gitlab-pages/docs/reference/toplevel.md +++ b/gitlab-pages/docs/reference/toplevel.md @@ -60,20 +60,56 @@ let (): unit A helper to create a unit. + -function failwith : string -> unit +function failwith : 'a -> unit -val failwith : string -> unit +val failwith : 'a -> unit -let failwith: string => unit +let failwith: 'a => unit -Cause the contract to fail with an error message. +Cause the contract to fail with an error message or integer. Other types are +not supported at the moment. + +Using this currently requires in general a type annotation on the +`failwith` call. + + + +```pascaligo +function main (const p : int; const s : unit) : list (operation) * unit is + block { + if p > 10 then failwith ("Failure.") else skip + } + with ((nil : list (operation)), s) +``` + + + + +```cameligo +let main (p,s : int * unit) = if p > 10 then failwith "Failure." +``` + + + + +```reasonligo +let main = ((p,s) : (int, unit)) => + if (p > 10) { failwith ("Failure."); }; +``` + + + +`Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead. + + +`Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead. + -> ⚠ Using this currently requires in general a type annotation on the -> `failwith` call. function assert : bool -> unit