Skip to content

Commit

Permalink
refactor: split files in diagnostics module
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstonskj committed Feb 16, 2024
1 parent fc02d43 commit 0d81d01
Show file tree
Hide file tree
Showing 8 changed files with 466 additions and 348 deletions.
1 change: 1 addition & 0 deletions sdml_error/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[package]
name = "sdml_error"
description = "Simple Domain Modeling Language (SDML) errors and diagnostics."
version = "0.1.0"
authors = ["Simon Johnston <johnstonskj@gmail.com>"]
repository = "https://github.com/johnstonskj/rust-sdml.git"
Expand Down
48 changes: 48 additions & 0 deletions sdml_error/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Crate sdlm_error

Rust Library containing the error and diagnostic types for the Simple Domain Modeling Language (SDML).

[![crates.io](https://img.shields.io/crates/v/sdml_generate.svg)](https://crates.io/crates/sdml_generate)
[![docs.rs](https://docs.rs/sdml_generate/badge.svg)](https://docs.rs/sdml_generate)

This package is part of the Rust SDML project and specifically defines the error and diagnostic types for the project.
The project's intent is to provide an idiomatic implementation of the in-memory model, parser, generators, and the CLI tool.

The following figure demonstrates this package in the broader project context.

```
╭───────╮
│ CLI │
╔══ │ crate │ ══╗
║ ╰───────╯ ║
┌╌╌╌╌╌╌╌╌┐ V V
┆ ┆ ╭──────────╮ ╭──────────╮ Formatted Source
┆ source ┆ ══> │ parse │ ══> │ generate │ ══> RDF Representation
┆ file ┆ ╭──│ crate │───────│ crate │──╮ Documentation
┆ ┆ │ ╰──────────╯ ╰──────────╯ │ Diagrams
└╌╌╌╌╌╌╌╌┘ │ core crate │──╮
╰───────────────────────────────────╯ │
┌───────┐ ⋀ error crate │
│ other │ ║ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌─────────────╯
│ tools │ ═══════════╝
└───────┘
```

## Changes

**Version 0.1.0**

Initial Release.

- Error Handling:
- Copy `error` module from `sdml_core`, rename as `errors`.
- Remove diagnostics from the existing `Error` type.
- Diagnostics:
- Copy `diagnostics` module.
- Create new `diagnostics::codes` module and `ErrorCode` enum.
- Create new `diagnostics::functions` module and functions for each `ErrorCode`.
- Diagnostic Reporting:
- Create new `diagnostics::reporter` module.
- Create new `Reporter` trait.
- Create a `StandardStreamReporter` to emit colored and structured errors to the console.
- Create a `BailoutReporter` that will turn the first diagnostic it is given into an error.
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
/*!
One-line description.
More detailed description, with
# Example
End of file during parsingSymbol’s value as variable is void: rustEnd of file during parsing
The [`ErrorCode`] type represents the set of conditions reported by the Diagnostics system.
*/

use codespan_reporting::diagnostic::Severity;
Expand Down

0 comments on commit 0d81d01

Please sign in to comment.