what to do: using the error wrapping %w feature of Go 1.13, achieve the below requirement.
1) create a function that can return 3 different errors (like id not found, db connection failed, invalid data) based on the input
2) call this function in another calling function, and write code in if err != nil{} block to identify the type of the error, and respond correctly. example. if error is "id not found" type print 404, if error is "db connection failed" type, print 500, if error is of "invalid data" type, print 400
ref: https://blog.golang.org/go1.13-errors
what to do: using the error wrapping
%w
feature of Go 1.13, achieve the below requirement. 1) create a function that can return 3 different errors (like id not found, db connection failed, invalid data) based on the input 2) call this function in another calling function, and write code inif err != nil{}
block to identify the type of the error, and respond correctly. example. if error is "id not found" type print404
, if error is "db connection failed" type, print500
, if error is of "invalid data" type, print400