Comments (8)
I'd like to follow the style of Rust error messages, because they rock.
Note to self: have a look at https://github.com/rust-lang/rust/blob/master/src/librustc_errors/lib.rs
from dhall-rust.
First step done ! #114
from dhall-rust.
Next step: #116
from dhall-rust.
Most of the groundwork is done, now there's mostly a need of writing nice error messages.
from dhall-rust.
The state of error messages can be seen in the .txt
files in dhall/tests/.../failure/...
. For example:
This is not amazing yet, but at least it points to the correct location in the source file. Some errors fail to do even that, either because of some complicated
Span
story or because we don't even try (see e.g. import errors).The goal would be better error messages like this one:
from dhall-rust.
Errors are not pretty printed in test outputs. It seems like it is attempting to use the Debug
version instead. For example this is the output when I tried to create a test case for the issue in #173
---- test_rename_all_camel_case stdout ----
thread 'test_rename_all_camel_case' panicked at 'called `Result::unwrap()` on an `Err` value: Error(Dhall(Error { kind: Typecheck(TypeError { message: Custom("error: annot mismatch: { function : Text, mergeVariant : Optional Text, postVariant : Optional Text, preVariant : Optional Text } != { function : Text, `merge_variant` : Optional Text, `post_variant` : Optional Text, `pre_variant` : Optional Text }\n --> <current file>:2:1\n |\n... |\n6 | | }\n | |______^ annot mismatch: { function : Text, mergeVariant : Optional Text, postVariant : Optional Text, preVariant : Optional Text } != { function : Text, `merge_variant` : Optional Text, `post_variant` : Optional Text, `pre_variant` : Optional Text }\n |") }) }))', serde_dhall/tests/rename.rs:33:10
from dhall-rust.
You get this output because you used .unwrap()
in your test case. .unwrap()
will indeed use the Debug
impl to display the values, which is not nice here. The way I would do it here is just define a parse
function that extracts the error and manually prints is with its Display
impl. Something like
fn parse<T: FromDhall + StaticType>(s: &str) -> T {
match from_str(s).static_type_annotation().parse() {
Ok(x) => x,
Err(e) => panic!("{}", e),
}
}
and then use parse::<Transform>(test_str)
. It's a bit annoying but the Debug
impl is often useful for tricky cases so I want to keep it around.
from dhall-rust.
I created a relevant issue: #228
from dhall-rust.
Related Issues (20)
- Deserialize binary dhall? HOT 9
- Naturals are bounded HOT 5
- RUSTSEC-2020-0016: `net2` crate has been deprecated; use `socket2` instead HOT 1
- RUSTSEC-2020-0095: difference is unmaintained
- Running functions? HOT 4
- can't build serde_dhall as dep of my project HOT 3
- RUSTSEC-2020-0146: arr! macro erases lifetimes
- `#[derive(StaticType)]` triggers the `redundant_semicolons` warning HOT 2
- Remote->Remote import chaining HOT 1
- Extremely slow parsing times HOT 2
- home-anchored imports don't work
- RUSTSEC-2021-0127: serde_cbor is unmaintained HOT 1
- Tilde does not expand to home dir HOT 2
- Conversions to Pest of 0-repetition ABNF rules fail HOT 1
- generic error message for duplicate field: RecordTypeMergeRequiresRecordType with no line reference HOT 1
- Serializing record of enums: `Serialize` is not implemented for `SimpleType` HOT 3
- RUSTSEC-2021-0139: ansi_term is Unmaintained
- Add new custom builtin functions HOT 1
- Support predefined `ABNF` core rules HOT 1
- abnf to pest issues HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dhall-rust.