Skip to content

fix: convert errors, return error from match_cmp_type#14

Open
Shawermik wants to merge 3 commits intofix-type-conversionfrom
add_errors
Open

fix: convert errors, return error from match_cmp_type#14
Shawermik wants to merge 3 commits intofix-type-conversionfrom
add_errors

Conversation

@Shawermik
Copy link
Collaborator

No description provided.

jsonpath.lua Outdated
return jsonpath
end)()

local function Bad_request_error(err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad_request_error

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил

jsonpath.lua Outdated

local function Bad_request_error(err)
local err = JsonPathError:new(err)
err.rc = codes.BAD_REQUEST
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

отступ поехал

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил

jsonpath.lua Outdated
if type(obj) ~= "table" then
return nil, 'object is primitive'
local err = JsonPathNotFoundError:new('object is primitive')
err.rc = codes.NOT_FOUND
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тогда и для всех остальных ошибок хелперы бы завести

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Завел

jsonpath.lua Outdated
local M = {}

local codes = {
SUCCESS = 200,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUCCESS - не используется

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил

Copy link
Collaborator

@alrsorokin alrsorokin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пробегись по всему коду где ошибка кладется сначала в переменную


return nil, 'no element matching expression'
local err = bad_request_error('no element matching expression')
return nil, err
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return nil, bad_request_error('no element matching expression')

if count ~= nil and type(count) ~= 'number' then
return nil, "invalid 'count' argument"
local err = bad_request_error("invalid 'count' argument")
return nil, err
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return nil, bad_request_error("invalid 'count' argument")

if expr == nil or (type(expr) ~= 'string' and type(expr) ~= 'table') then
return nil, "missing or invalid 'expr' argument"
local err = bad_request_error("missing or invalid 'expr' argument")
return nil, err
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return nil, bad_request_error("missing or invalid 'expr' argument")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants