···4041type UpdateNotificationPreferencesError {
42 /// Authentication failed
43- AccessControl(session.SessionError)
44 /// Failed to query Database
45 DataBase(pog.QueryError)
46 NotFound
···7879fn handle_error(err: UpdateNotificationPreferencesError) -> wisp.Response {
80 case err {
81- AccessControl(err) -> session.handle_error(err)
82 DataBase(err) -> web.handle_database_error(err)
83 NotFound ->
84 "O banco de dados não retornou resultados após atualizar as preferências"
···97) {
98 use token <- result.try(
99 session.extract(req)
100- |> result.map_error(AccessControl),
101 )
102103 use acc, #(key, value) <- list.try_fold(
···4041type UpdateNotificationPreferencesError {
42 /// Authentication failed
43+ Session(session.SessionError)
44 /// Failed to query Database
45 DataBase(pog.QueryError)
46 NotFound
···7879fn handle_error(err: UpdateNotificationPreferencesError) -> wisp.Response {
80 case err {
81+ Session(err) -> session.handle_error(err)
82 DataBase(err) -> web.handle_database_error(err)
83 NotFound ->
84 "O banco de dados não retornou resultados após atualizar as preferências"
···97) {
98 use token <- result.try(
99 session.extract(req)
100+ |> result.map_error(Session),
101 )
102103 use acc, #(key, value) <- list.try_fold(
+3-3
src/app/domain/occurrence/close_occurrence.gleam
···23 /// An error occurred whe naccessing the DataBase
24 DataBase(pog.QueryError)
25 /// Errors related to authentication / authorization
26- AccessControl(session.SessionError)
27}
2829/// Updates the `resolved_at` field of a occurrence
···55) -> Result(String, ResolveOccurrenceError) {
56 use _ <- result.try(
57 session.extract(req)
58- |> result.map_error(AccessControl),
59 )
6061 use target <- result.try(
···102103fn handle_error(err: ResolveOccurrenceError) -> wisp.Response {
104 case err {
105- AccessControl(err) -> session.handle_error(err)
106 DataBase(err) -> web.handle_database_error(err)
107 InvalidUuid(id) ->
108 wisp.bad_request("Ocorrência possui Uuid inválido: " <> id)
···23 /// An error occurred whe naccessing the DataBase
24 DataBase(pog.QueryError)
25 /// Errors related to authentication / authorization
26+ Session(session.SessionError)
27}
2829/// Updates the `resolved_at` field of a occurrence
···55) -> Result(String, ResolveOccurrenceError) {
56 use _ <- result.try(
57 session.extract(req)
58+ |> result.map_error(Session),
59 )
6061 use target <- result.try(
···102103fn handle_error(err: ResolveOccurrenceError) -> wisp.Response {
104 case err {
105+ Session(err) -> session.handle_error(err)
106 DataBase(err) -> web.handle_database_error(err)
107 InvalidUuid(id) ->
108 wisp.bad_request("Ocorrência possui Uuid inválido: " <> id)
+3-3
src/app/domain/occurrence/delete_occurrence.gleam
···15 /// Occurrence has invalid Uuid
16 InvalidUuid(String)
17 /// Authentication failed
18- AccessControl(session.SessionError)
19 /// Failed to query the DataBase
20 DataBase(pog.QueryError)
21 /// Occurrence was not found in the system
···58 use _ <- result.try(
59 // Armazenamos o UUID do usuário caso precisemos para autorização
60 session.extract(req)
61- |> result.map_error(AccessControl),
62 )
6364 use returned <- result.try(
···81 InvalidUuid(uuid_string) ->
82 // 404 Bad Request
83 wisp.bad_request("UUID inválido: " <> uuid_string)
84- AccessControl(err) -> session.handle_error(err)
85 DataBase(db_err) -> web.handle_database_error(db_err)
86 OccurrenceNotFound(occ_uuid) -> {
87 // 404 not found
···15 /// Occurrence has invalid Uuid
16 InvalidUuid(String)
17 /// Authentication failed
18+ Session(session.SessionError)
19 /// Failed to query the DataBase
20 DataBase(pog.QueryError)
21 /// Occurrence was not found in the system
···58 use _ <- result.try(
59 // Armazenamos o UUID do usuário caso precisemos para autorização
60 session.extract(req)
61+ |> result.map_error(Session),
62 )
6364 use returned <- result.try(
···81 InvalidUuid(uuid_string) ->
82 // 404 Bad Request
83 wisp.bad_request("UUID inválido: " <> uuid_string)
84+ Session(err) -> session.handle_error(err)
85 DataBase(db_err) -> web.handle_database_error(db_err)
86 OccurrenceNotFound(occ_uuid) -> {
87 // 404 not found