Skip to content

Commit 2d5ce58

Browse files
author
Sebastian Wilgosz
committed
Add *.md linter to repository
1 parent dd51ec3 commit 2d5ce58

File tree

4 files changed

+2764
-31
lines changed

4 files changed

+2764
-31
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/_yardoc/
44
/coverage/
55
/doc/
6+
/node_modules
67
/pkg/
78
/spec/reports/
89
/tmp/

README.md

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
# JsonapiErrorsHandler
66

7-
A convienient way to serialize errors in JsonAPI format (https://jsonapi.org)
7+
A convienient way to serialize errors in [Jsonapi standard](https://jsonapi.org)
88

99
## Installation
1010

1111
Add this line to your application's Gemfile:
1212

1313
```ruby
14-
gem 'jsonapi_errors_handler'
14+
gem 'jsonapi_errors_handler'
1515
```
1616

1717
And then execute:
@@ -26,30 +26,31 @@ Or install it yourself as:
2626

2727
In your controller:
2828

29-
```
30-
include JsonapiErrorsHandler
31-
rescue_from ::StandardError, with: lambda { |e| handle_error(e) }
29+
```ruby
30+
include JsonapiErrorsHandler
31+
rescue_from ::StandardError, with: lambda { |e| handle_error(e) }
3232
```
3333

3434
From this point you'll have default html errors being serialized. JsonapiErrorsHandler offers 4 predefined errors:
35-
- [JsonapiErrorsHandler::Errors::Invalid](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/invalid.rb)
36-
- [JsonapiErrorsHandler::Errors::Forbidden](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/forbidden.rb)
37-
- [JsonapiErrorsHandler::Errors::NotFound](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/not_found.rb)
38-
- [JsonapiErrorsHandler::Errors::Unauthorized](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/not_found.rb)
35+
36+
* [JsonapiErrorsHandler::Errors::Invalid](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/invalid.rb)
37+
* [JsonapiErrorsHandler::Errors::Forbidden](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/forbidden.rb)
38+
* [JsonapiErrorsHandler::Errors::NotFound](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/not_found.rb)
39+
* [JsonapiErrorsHandler::Errors::Unauthorized](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/not_found.rb)
3940

4041
If you rise any of errors above in any place of your application, client gets the nicely formatted error message instead of 500
4142

4243
### Custom errors mapping
4344

4445
If you want your custom errors being handled by default, just add them to the mapper
4546

46-
```
47-
include JsonapiErrorsHandler
48-
ErrorsMapper.map_errors!({
49-
'ActiveRecord::RecordNotFound' => 'JsonapiErrorsHandler::Errors::NotFound',
50-
'ActiveRecord::RecordInvalid' => 'JsonapiErrorsHandler::Errors::Invalid',
51-
})
52-
rescue_from ::StandardError, with: lambda { |e| handle_error(e) }
47+
```ruby
48+
include JsonapiErrorsHandler
49+
ErrorsMapper.map_errors!({
50+
'ActiveRecord::RecordNotFound' => 'JsonapiErrorsHandler::Errors::NotFound',
51+
'ActiveRecord::RecordInvalid' => 'JsonapiErrorsHandler::Errors::Invalid',
52+
})
53+
rescue_from ::StandardError, with: lambda { |e| handle_error(e) }
5354
```
5455

5556
###Custom error logging
@@ -68,14 +69,14 @@ To do so, just implement the `log_error` method in your controller, that accepts
6869
end
6970
```
7071

71-
### Custom error responses.
72+
### Custom error responses
7273

7374
By default, we deliver hardcoded responses. You can check out the defined error classes for details
7475

75-
- [JsonapiErrorsHandler::Errors::Invalid](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/invalid.rb)
76-
- [JsonapiErrorsHandler::Errors::Forbidden](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/forbidden.rb)
77-
- [JsonapiErrorsHandler::Errors::NotFound](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/not_found.rb)
78-
- [JsonapiErrorsHandler::Errors::Unauthorized](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/not_found.rb)
76+
* [JsonapiErrorsHandler::Errors::Invalid](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/invalid.rb)
77+
* [JsonapiErrorsHandler::Errors::Forbidden](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/forbidden.rb)
78+
* [JsonapiErrorsHandler::Errors::NotFound](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/not_found.rb)
79+
* [JsonapiErrorsHandler::Errors::Unauthorized](https://github.com/driggl/jsonapi_errors_handler/blob/master/lib/jsonapi_errors_handler/errors/not_found.rb)
7980

8081
If you want to have custom error responses being delivered, just create your own `Api::Errors` that inherits from `JsonapiErrorsHandler::StandardError`
8182

@@ -100,8 +101,8 @@ If you want to localize your responses, just create a class:
100101

101102
## Guides & tutorials
102103

103-
- [Handling Exceptions in Rails Applications](https://driggl.com/blog/a/handling-exceptions-in-rails-applications) - Gem's concept explained in details
104-
- [JsonApi Errors Handler Guide](https://driggl.com/blog/a/json-api-errors-handler)
104+
* [Handling Exceptions in Rails Applications](https://driggl.com/blog/a/handling-exceptions-in-rails-applications) - Gem's concept explained in details
105+
* [JsonApi Errors Handler Guide](https://driggl.com/blog/a/json-api-errors-handler)
105106

106107
## Development
107108

@@ -111,17 +112,17 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
111112

112113
## Contributing
113114

114-
Bug reports and pull requests are welcome on GitHub at https://github.com/driggl/jsonapi_errors_handler.
115+
Bug reports and pull requests are welcome on GitHub at [https://github.com/driggl/jsonapi_errors_handler](https://github.com/driggl/jsonapi_errors_handler).
115116

116117
**How to contribute:**
117118

118-
1. Fork repository
119-
2. Install [Rubocop](https://github.com/rubocop-hq/rubocop) - make sure you run it before commiting changes
120-
2. Commit changes
121-
- Keep commits small and atomic
122-
- Start commit message from keywords (Add/Remove/Change/Refactor/Move/Rename/Upgrade/Downgrade)
123-
- Keep commits imperative style
124-
3. Create Pull Request
119+
1. Fork repository
120+
2. Install [Rubocop](https://github.com/rubocop-hq/rubocop) - make sure you run it before commiting changes
121+
3. Commit changes
122+
* Keep commits small and atomic
123+
* Start commit message from keywords (Add/Remove/Change/Refactor/Move/Rename/Upgrade/Downgrade)
124+
* Keep commits imperative style
125+
4. Create Pull Request
125126

126127
## License
127128

0 commit comments

Comments
 (0)