Skip to content

Commit 70878ce

Browse files
author
Sebastian Wilgosz
committed
Refactor to add top-level class documentation for error classes
1 parent 9051e0b commit 70878ce

5 files changed

Lines changed: 14 additions & 1 deletion

File tree

lib/jsonapi_errors_handler/errors/forbidden.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module JsonapiErrorsHandler
44
module Errors
5+
# Handles serialization of forbidden HTTP error (403 status code)
6+
#
57
class Forbidden < ::JsonapiErrorsHandler::Errors::StandardError
68
def initialize(message: nil)
79
super(

lib/jsonapi_errors_handler/errors/invalid.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module JsonapiErrorsHandler
44
module Errors
5+
# Handles serialization of invalid HTTP error (422 status code)
6+
#
57
class Invalid < ::JsonapiErrorsHandler::Errors::StandardError
68
def initialize(errors: {})
79
@errors = errors

lib/jsonapi_errors_handler/errors/not_found.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module JsonapiErrorsHandler
44
module Errors
5+
# Handles serialization of NotFound HTTP error (404 status code)
6+
#
57
class NotFound < ::JsonapiErrorsHandler::Errors::StandardError
68
def initialize(message: nil)
79
super(

lib/jsonapi_errors_handler/errors/standard_error.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44

55
module JsonapiErrorsHandler
66
module Errors
7+
# Handles serialization of Unexpected HTTP error (500 status code)
8+
# It's also a fallback for not mapped errors in the application.
9+
#
710
class StandardError < ::StandardError
8-
def initialize(title: nil, status: nil, detail: nil, message: nil, source: {})
11+
def initialize(
12+
title: nil, status: nil, detail: nil, message: nil, source: {}
13+
)
914
@title = title || 'Something went wrong'
1015
@detail = detail || message
1116
@detail ||= "We've encountered unexpected error, but our developers had been already notified about it" # rubocop:disable Metrics/LineLength

lib/jsonapi_errors_handler/errors/unauthorized.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module JsonapiErrorsHandler
44
module Errors
5+
# Handles serialization of Unauthorized HTTP error (401 status code)
6+
#
57
class Unauthorized < ::JsonapiErrorsHandler::Errors::StandardError
68
def initialize(message: nil)
79
super(

0 commit comments

Comments
 (0)