| ... | @@ -3273,13 +3273,13 @@ const err = (error {FileNotFound}).FileNotFound; | ... | @@ -3273,13 +3273,13 @@ const err = (error {FileNotFound}).FileNotFound; |
| 3273 | This becomes useful when using {#link|Inferred Error Sets#}. | 3273 | This becomes useful when using {#link|Inferred Error Sets#}. |
| 3274 | </p> | 3274 | </p> |
| 3275 | {#header_open|The Global Error Set#} | 3275 | {#header_open|The Global Error Set#} |
| 3276 | <p>{#syntax#}error{#endsyntax#} refers to the global error set. | 3276 | <p>{#syntax#}anyerror{#endsyntax#} refers to the global error set. |
| 3277 | This is the error set that contains all errors in the entire compilation unit. | 3277 | This is the error set that contains all errors in the entire compilation unit. |
| 3278 | It is a superset of all other error sets and a subset of none of them. | 3278 | It is a superset of all other error sets and a subset of none of them. |
| 3279 | </p> | 3279 | </p> |
| 3280 | <p> | 3280 | <p> |
| 3281 | You can implicitly cast any error set to the global one, and you can explicitly | 3281 | You can implicitly cast any error set to the global one, and you can explicitly |
| 3282 | cast an error of global error set to a non-global one. This inserts a language-level | 3282 | cast an error of the global error set to a non-global one. This inserts a language-level |
| 3283 | assert to make sure the error value is in fact in the destination error set. | 3283 | assert to make sure the error value is in fact in the destination error set. |
| 3284 | </p> | 3284 | </p> |
| 3285 | <p> | 3285 | <p> |
| ... | @@ -5601,18 +5601,14 @@ test "main" { | ... | @@ -5601,18 +5601,14 @@ test "main" { |
| 5601 | {#header_close#} | 5601 | {#header_close#} |
| 5602 | | 5602 | |
| 5603 | {#header_open|@errorName#} | 5603 | {#header_open|@errorName#} |
| 5604 | <pre>{#syntax#}@errorName(err: error) []u8{#endsyntax#}</pre> | 5604 | <pre>{#syntax#}@errorName(err: anyerror) []const u8{#endsyntax#}</pre> |
| 5605 | <p> | 5605 | <p> |
| 5606 | This function returns the string representation of an error. If an error | 5606 | This function returns the string representation of an error. The string representation |
| 5607 | declaration is: | 5607 | of {#syntax#}error.OutOfMem{#endsyntax#} is {#syntax#}"OutOfMem"{#endsyntax#}. |
| 5608 | </p> | | |
| 5609 | <pre>{#syntax#}error OutOfMem{#endsyntax#}</pre> | | |
| 5610 | <p> | | |
| 5611 | Then the string representation is {#syntax#}"OutOfMem"{#endsyntax#}. | | |
| 5612 | </p> | 5608 | </p> |
| 5613 | <p> | 5609 | <p> |
| 5614 | If there are no calls to {#syntax#}@errorName{#endsyntax#} in an entire application, | 5610 | If there are no calls to {#syntax#}@errorName{#endsyntax#} in an entire application, |
| 5615 | or all calls have a compile-time known value for {#syntax#}err{#endsyntax#}, then no | 5611 | or all calls have a compile-time known value for {#syntax#}err{#endsyntax#}, then no |
| 5616 | error name table will be generated. | 5612 | error name table will be generated. |
| 5617 | </p> | 5613 | </p> |
| 5618 | {#header_close#} | 5614 | {#header_close#} |
| ... | @@ -5627,13 +5623,14 @@ test "main" { | ... | @@ -5627,13 +5623,14 @@ test "main" { |
| 5627 | {#header_close#} | 5623 | {#header_close#} |
| 5628 | | 5624 | |
| 5629 | {#header_open|@errorToInt#} | 5625 | {#header_open|@errorToInt#} |
| 5630 | <pre>{#syntax#}@errorToInt(err: var) @IntType(false, @sizeOf(error) * 8){#endsyntax#}</pre> | 5626 | <pre>{#syntax#}@errorToInt(err: var) @IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}</pre> |
| 5631 | <p> | 5627 | <p> |
| 5632 | Supports the following types: | 5628 | Supports the following types: |
| 5633 | </p> | 5629 | </p> |
| 5634 | <ul> | 5630 | <ul> |
| 5635 | <li>error unions</li> | 5631 | <li>{#link|The Global Error Set#}</li> |
| 5636 | <li>{#syntax#}E!void{#endsyntax#}</li> | 5632 | <li>{#link|Error Set Type#}</li> |
| | 5633 | <li>{#link|Error Union Type#}</li> |
| 5637 | </ul> | 5634 | </ul> |
| 5638 | <p> | 5635 | <p> |
| 5639 | Converts an error to the integer representation of an error. | 5636 | Converts an error to the integer representation of an error. |
| ... | @@ -5788,7 +5785,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } | ... | @@ -5788,7 +5785,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } |
| 5788 | {#header_open|@intToError#} | 5785 | {#header_open|@intToError#} |
| 5789 | <pre>{#syntax#}@intToError(value: @IntType(false, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre> | 5786 | <pre>{#syntax#}@intToError(value: @IntType(false, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre> |
| 5790 | <p> | 5787 | <p> |
| 5791 | Converts from the integer representation of an error into the global error set type. | 5788 | Converts from the integer representation of an error into {#link|The Global Error Set#} type. |
| 5792 | </p> | 5789 | </p> |
| 5793 | <p> | 5790 | <p> |
| 5794 | It is generally recommended to avoid this | 5791 | It is generally recommended to avoid this |