Result<T, E>
overhaul.
Background:
- The main use-case of
Result<T, E>
is to serve as return of a function that can either have a successful result of
typeT
or an error of typeE
. - In pretty much all cases the error is just a
string
, i.e. the common use isResult<T, string>
Changes:
- For simplification the type parameter for the error case is dropped, i.e. a result is just
Result<T>
- The old notation
Result<T, E>
(or ratherResult<T, string>
) will still work, but the second parameter is ignored
- The old notation
- The
result.error
field is now a newly introducedcore::error::Error
- For compatibility
core::error::Error
will be automatically converted to a string - Just like before an error
Result
can be created using the builtinErr
function with an error message
- For compatibility
- In addition to the error
message
thecore::error::Error
additional contains astack_trace
to help locating
where theError
was created - As an additional helper there this a
core::error::current_stack()
function to obtain the current stack trace for
debugging purposes.
Support for script based logs:
- Add
MAIN_LOG
andopen_log_file(string)
toksp::debug
- Log files will be cared ein
logs
sub-folder ofto2Local
- Log files will be cared ein