3
0

System error def namings & log messages improvements

This commit is contained in:
Denis Arh 2020-05-28 21:49:35 +02:00
parent d70fde7f8b
commit f99ca1e9be
17 changed files with 92 additions and 93 deletions

View File

@ -498,19 +498,19 @@ func ApplicationErrGeneric(props ...*applicationActionProps) *applicationError {
}
// ApplicationErrNonexistent returns "system:application.nonexistent" audit event as actionlog.Warning
// ApplicationErrNotFound returns "system:application.notFound" audit event as actionlog.Warning
//
//
// This function is auto-generated.
//
func ApplicationErrNonexistent(props ...*applicationActionProps) *applicationError {
func ApplicationErrNotFound(props ...*applicationActionProps) *applicationError {
var e = &applicationError{
timestamp: time.Now(),
resource: "system:application",
error: "nonexistent",
error: "notFound",
action: "error",
message: "application does not exist",
log: "application does not exist",
message: "application not found",
log: "application not found",
severity: actionlog.Warning,
props: func() *applicationActionProps {
if len(props) > 0 {
@ -569,7 +569,7 @@ func ApplicationErrNotAllowedToRead(props ...*applicationActionProps) *applicati
resource: "system:application",
error: "notAllowedToRead",
action: "error",
message: "not allowed to read application",
message: "not allowed to read this application",
log: "failed to read {application.name}; insufficient permissions",
severity: actionlog.Error,
props: func() *applicationActionProps {
@ -629,7 +629,7 @@ func ApplicationErrNotAllowedToCreate(props ...*applicationActionProps) *applica
resource: "system:application",
error: "notAllowedToCreate",
action: "error",
message: "not allowed to create application",
message: "not allowed to create applications",
log: "failed to create application; insufficient permissions",
severity: actionlog.Error,
props: func() *applicationActionProps {
@ -659,7 +659,7 @@ func ApplicationErrNotAllowedToUpdate(props ...*applicationActionProps) *applica
resource: "system:application",
error: "notAllowedToUpdate",
action: "error",
message: "not allowed to update application",
message: "not allowed to update this application",
log: "failed to update {application.name}; insufficient permissions",
severity: actionlog.Error,
props: func() *applicationActionProps {
@ -689,7 +689,7 @@ func ApplicationErrNotAllowedToDelete(props ...*applicationActionProps) *applica
resource: "system:application",
error: "notAllowedToDelete",
action: "error",
message: "not allowed to delete application",
message: "not allowed to delete this application",
log: "failed to delete {application.name}; insufficient permissions",
severity: actionlog.Error,
props: func() *applicationActionProps {
@ -719,7 +719,7 @@ func ApplicationErrNotAllowedToUndelete(props ...*applicationActionProps) *appli
resource: "system:application",
error: "notAllowedToUndelete",
action: "error",
message: "not allowed to undelete application",
message: "not allowed to undelete this application",
log: "failed to undelete {application.name}; insufficient permissions",
severity: actionlog.Error,
props: func() *applicationActionProps {

View File

@ -48,8 +48,8 @@ actions:
log: "undeleted {application}"
errors:
- error: nonexistent
message: "application does not exist"
- error: notFound
message: "application not found"
severity: warning
- error: invalidID
@ -57,7 +57,7 @@ errors:
severity: warning
- error: notAllowedToRead
message: "not allowed to read application"
message: "not allowed to read this application"
log: "failed to read {application.name}; insufficient permissions"
- error: notAllowedToListApplications
@ -65,17 +65,17 @@ errors:
log: "failed to list application; insufficient permissions"
- error: notAllowedToCreate
message: "not allowed to create application"
message: "not allowed to create applications"
log: "failed to create application; insufficient permissions"
- error: notAllowedToUpdate
message: "not allowed to update application"
message: "not allowed to update this application"
log: "failed to update {application.name}; insufficient permissions"
- error: notAllowedToDelete
message: "not allowed to delete application"
message: "not allowed to delete this application"
log: "failed to delete {application.name}; insufficient permissions"
- error: notAllowedToUndelete
message: "not allowed to undelete application"
message: "not allowed to undelete this application"
log: "failed to undelete {application.name}; insufficient permissions"

View File

@ -141,7 +141,6 @@ func (svc attachment) Find(filter types.AttachmentFilter) (aa types.AttachmentSe
})
return aa, f, svc.recordAction(svc.ctx, aaProps, AttachmentActionSearch, err)
}
func (svc attachment) OpenOriginal(att *types.Attachment) (io.ReadSeeker, error) {

View File

@ -466,19 +466,19 @@ func AttachmentErrGeneric(props ...*attachmentActionProps) *attachmentError {
}
// AttachmentErrNonexistent returns "system:attachment.nonexistent" audit event as actionlog.Warning
// AttachmentErrNotFound returns "system:attachment.notFound" audit event as actionlog.Warning
//
//
// This function is auto-generated.
//
func AttachmentErrNonexistent(props ...*attachmentActionProps) *attachmentError {
func AttachmentErrNotFound(props ...*attachmentActionProps) *attachmentError {
var e = &attachmentError{
timestamp: time.Now(),
resource: "system:attachment",
error: "nonexistent",
error: "notFound",
action: "error",
message: "attachment does not exist",
log: "attachment does not exist",
message: "attachment not found",
log: "attachment not found",
severity: actionlog.Warning,
props: func() *attachmentActionProps {
if len(props) > 0 {
@ -567,7 +567,7 @@ func AttachmentErrNotAllowedToCreate(props ...*attachmentActionProps) *attachmen
resource: "system:attachment",
error: "notAllowedToCreate",
action: "error",
message: "not allowed to create attachment",
message: "not allowed to create attachments",
log: "failed to create attachment; insufficient permissions",
severity: actionlog.Alert,
props: func() *attachmentActionProps {

View File

@ -41,8 +41,8 @@ actions:
log: "deleted {attachment}"
errors:
- error: nonexistent
message: "attachment does not exist"
- error: notFound
message: "attachment not found"
severity: warning
- error: invalidID
@ -54,7 +54,7 @@ errors:
log: "failed to list attachment; insufficient permissions"
- error: notAllowedToCreate
message: "not allowed to create attachment"
message: "not allowed to create attachments"
log: "failed to create attachment; insufficient permissions"
- error: failedToExtractMimeType

View File

@ -188,7 +188,7 @@ func (svc reminder) Dismiss(ctx context.Context, ID uint64) (err error) {
}
if r, err = svc.reminder.FindByID(ID); err != nil {
return ReminderErrNonexistent()
return ReminderErrNotFound()
}
raProps.setReminder(r)
@ -221,7 +221,7 @@ func (svc reminder) Snooze(ctx context.Context, ID uint64, remindAt *time.Time)
}
if r, err = svc.reminder.FindByID(ID); err != nil {
return ReminderErrNonexistent()
return ReminderErrNotFound()
}
raProps.setReminder(r)
@ -253,7 +253,7 @@ func (svc reminder) Delete(ctx context.Context, ID uint64) (err error) {
}
if r, err = svc.FindByID(ctx, ID); err != nil {
return ReminderErrNonexistent()
return ReminderErrNotFound()
}
raProps.setReminder(r)

View File

@ -557,19 +557,19 @@ func ReminderErrGeneric(props ...*reminderActionProps) *reminderError {
}
// ReminderErrNonexistent returns "system:reminder.nonexistent" audit event as actionlog.Warning
// ReminderErrNotFound returns "system:reminder.notFound" audit event as actionlog.Warning
//
//
// This function is auto-generated.
//
func ReminderErrNonexistent(props ...*reminderActionProps) *reminderError {
func ReminderErrNotFound(props ...*reminderActionProps) *reminderError {
var e = &reminderError{
timestamp: time.Now(),
resource: "system:reminder",
error: "nonexistent",
error: "notFound",
action: "error",
message: "reminder does not exist",
log: "reminder does not exist",
message: "reminder not found",
log: "reminder not found",
severity: actionlog.Warning,
props: func() *reminderActionProps {
if len(props) > 0 {

View File

@ -51,8 +51,8 @@ actions:
log: "deleted {reminder}"
errors:
- error: nonexistent
message: "reminder does not exist"
- error: notFound
message: "reminder not found"
severity: warning
- error: invalidID

View File

@ -741,19 +741,19 @@ func RoleErrGeneric(props ...*roleActionProps) *roleError {
}
// RoleErrNonexistent returns "system:role.nonexistent" audit event as actionlog.Warning
// RoleErrNotFOund returns "system:role.notFOund" audit event as actionlog.Warning
//
//
// This function is auto-generated.
//
func RoleErrNonexistent(props ...*roleActionProps) *roleError {
func RoleErrNotFOund(props ...*roleActionProps) *roleError {
var e = &roleError{
timestamp: time.Now(),
resource: "system:role",
error: "nonexistent",
error: "notFOund",
action: "error",
message: "role does not exist",
log: "role does not exist",
message: "role not found",
log: "role not found",
severity: actionlog.Warning,
props: func() *roleActionProps {
if len(props) > 0 {
@ -842,7 +842,7 @@ func RoleErrNotAllowedToRead(props ...*roleActionProps) *roleError {
resource: "system:role",
error: "notAllowedToRead",
action: "error",
message: "not allowed to read role",
message: "not allowed to read this role",
log: "failed to read {role.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *roleActionProps {
@ -902,7 +902,7 @@ func RoleErrNotAllowedToCreate(props ...*roleActionProps) *roleError {
resource: "system:role",
error: "notAllowedToCreate",
action: "error",
message: "not allowed to create role",
message: "not allowed to create roles",
log: "failed to create role; insufficient permissions",
severity: actionlog.Alert,
props: func() *roleActionProps {
@ -932,7 +932,7 @@ func RoleErrNotAllowedToUpdate(props ...*roleActionProps) *roleError {
resource: "system:role",
error: "notAllowedToUpdate",
action: "error",
message: "not allowed to update role",
message: "not allowed to update this role",
log: "failed to update {role.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *roleActionProps {
@ -962,7 +962,7 @@ func RoleErrNotAllowedToDelete(props ...*roleActionProps) *roleError {
resource: "system:role",
error: "notAllowedToDelete",
action: "error",
message: "not allowed to delete role",
message: "not allowed to delete this role",
log: "failed to delete {role.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *roleActionProps {
@ -992,7 +992,7 @@ func RoleErrNotAllowedToUndelete(props ...*roleActionProps) *roleError {
resource: "system:role",
error: "notAllowedToUndelete",
action: "error",
message: "not allowed to undelete role",
message: "not allowed to undelete this role",
log: "failed to undelete {role.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *roleActionProps {
@ -1022,7 +1022,7 @@ func RoleErrNotAllowedToArchive(props ...*roleActionProps) *roleError {
resource: "system:role",
error: "notAllowedToArchive",
action: "error",
message: "not allowed to archive role",
message: "not allowed to archive this role",
log: "failed to archive {role.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *roleActionProps {
@ -1052,7 +1052,7 @@ func RoleErrNotAllowedToUnarchive(props ...*roleActionProps) *roleError {
resource: "system:role",
error: "notAllowedToUnarchive",
action: "error",
message: "not allowed to unarchive role",
message: "not allowed to unarchive this role",
log: "failed to unarchive {role.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *roleActionProps {

View File

@ -76,8 +76,8 @@ actions:
errors:
- error: nonexistent
message: "role does not exist"
- error: notFOund
message: "role not found"
severity: warning
- error: invalidID
@ -89,7 +89,7 @@ errors:
severity: warning
- error: notAllowedToRead
message: "not allowed to read role"
message: "not allowed to read this role"
log: "failed to read {role.handle}; insufficient permissions"
- error: notAllowedToListRoles
@ -97,27 +97,27 @@ errors:
log: "failed to list role; insufficient permissions"
- error: notAllowedToCreate
message: "not allowed to create role"
message: "not allowed to create roles"
log: "failed to create role; insufficient permissions"
- error: notAllowedToUpdate
message: "not allowed to update role"
message: "not allowed to update this role"
log: "failed to update {role.handle}; insufficient permissions"
- error: notAllowedToDelete
message: "not allowed to delete role"
message: "not allowed to delete this role"
log: "failed to delete {role.handle}; insufficient permissions"
- error: notAllowedToUndelete
message: "not allowed to undelete role"
message: "not allowed to undelete this role"
log: "failed to undelete {role.handle}; insufficient permissions"
- error: notAllowedToArchive
message: "not allowed to archive role"
message: "not allowed to archive this role"
log: "failed to archive {role.handle}; insufficient permissions"
- error: notAllowedToUnarchive
message: "not allowed to unarchive role"
message: "not allowed to unarchive this role"
log: "failed to unarchive {role.handle}; insufficient permissions"
- error: notAllowedToManageMembers

View File

@ -239,7 +239,7 @@ func (svc user) FindByAny(identifier interface{}) (u *types.User, err error) {
func (svc user) proc(u *types.User, err error) (*types.User, error) {
if err != nil {
if repository.ErrUserNotFound.Eq(err) {
return nil, UserErrNonexistent()
return nil, UserErrNotFound()
}
return nil, err

View File

@ -639,19 +639,19 @@ func UserErrGeneric(props ...*userActionProps) *userError {
}
// UserErrNonexistent returns "system:user.nonexistent" audit event as actionlog.Warning
// UserErrNotFound returns "system:user.notFound" audit event as actionlog.Warning
//
//
// This function is auto-generated.
//
func UserErrNonexistent(props ...*userActionProps) *userError {
func UserErrNotFound(props ...*userActionProps) *userError {
var e = &userError{
timestamp: time.Now(),
resource: "system:user",
error: "nonexistent",
error: "notFound",
action: "error",
message: "user does not exist",
log: "user does not exist",
message: "user not found",
log: "user not found",
severity: actionlog.Warning,
props: func() *userActionProps {
if len(props) > 0 {
@ -770,7 +770,7 @@ func UserErrNotAllowedToRead(props ...*userActionProps) *userError {
resource: "system:user",
error: "notAllowedToRead",
action: "error",
message: "not allowed to read user",
message: "not allowed to read this user",
log: "failed to read {user.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *userActionProps {
@ -830,8 +830,8 @@ func UserErrNotAllowedToCreate(props ...*userActionProps) *userError {
resource: "system:user",
error: "notAllowedToCreate",
action: "error",
message: "not allowed to create user",
log: "failed to create user; insufficient permissions",
message: "not allowed to create users",
log: "failed to create users; insufficient permissions",
severity: actionlog.Alert,
props: func() *userActionProps {
if len(props) > 0 {
@ -860,7 +860,7 @@ func UserErrNotAllowedToUpdate(props ...*userActionProps) *userError {
resource: "system:user",
error: "notAllowedToUpdate",
action: "error",
message: "not allowed to update user",
message: "not allowed to update this user",
log: "failed to update {user.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *userActionProps {
@ -890,7 +890,7 @@ func UserErrNotAllowedToDelete(props ...*userActionProps) *userError {
resource: "system:user",
error: "notAllowedToDelete",
action: "error",
message: "not allowed to delete user",
message: "not allowed to delete this user",
log: "failed to delete {user.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *userActionProps {
@ -920,7 +920,7 @@ func UserErrNotAllowedToUndelete(props ...*userActionProps) *userError {
resource: "system:user",
error: "notAllowedToUndelete",
action: "error",
message: "not allowed to undelete user",
message: "not allowed to undelete this user",
log: "failed to undelete {user.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *userActionProps {
@ -950,7 +950,7 @@ func UserErrNotAllowedToSuspend(props ...*userActionProps) *userError {
resource: "system:user",
error: "notAllowedToSuspend",
action: "error",
message: "not allowed to suspend user",
message: "not allowed to suspend this user",
log: "failed to suspend {user.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *userActionProps {
@ -980,7 +980,7 @@ func UserErrNotAllowedToUnsuspend(props ...*userActionProps) *userError {
resource: "system:user",
error: "notAllowedToUnsuspend",
action: "error",
message: "not allowed to unsuspend user",
message: "not allowed to unsuspend this user",
log: "failed to unsuspend {user.handle}; insufficient permissions",
severity: actionlog.Alert,
props: func() *userActionProps {

View File

@ -60,8 +60,8 @@ actions:
log: "password changed for {user}"
errors:
- error: nonexistent
message: "user does not exist"
- error: notFound
message: "user not found"
severity: warning
- error: invalidID
@ -78,7 +78,7 @@ errors:
- error: notAllowedToRead
message: "not allowed to read user"
message: "not allowed to read this user"
log: "failed to read {user.handle}; insufficient permissions"
- error: notAllowedToListUsers
@ -86,27 +86,27 @@ errors:
log: "failed to list user; insufficient permissions"
- error: notAllowedToCreate
message: "not allowed to create user"
log: "failed to create user; insufficient permissions"
message: "not allowed to create users"
log: "failed to create users; insufficient permissions"
- error: notAllowedToUpdate
message: "not allowed to update user"
message: "not allowed to update this user"
log: "failed to update {user.handle}; insufficient permissions"
- error: notAllowedToDelete
message: "not allowed to delete user"
message: "not allowed to delete this user"
log: "failed to delete {user.handle}; insufficient permissions"
- error: notAllowedToUndelete
message: "not allowed to undelete user"
message: "not allowed to undelete this user"
log: "failed to undelete {user.handle}; insufficient permissions"
- error: notAllowedToSuspend
message: "not allowed to suspend user"
message: "not allowed to suspend this user"
log: "failed to suspend {user.handle}; insufficient permissions"
- error: notAllowedToUnsuspend
message: "not allowed to unsuspend user"
message: "not allowed to unsuspend this user"
log: "failed to unsuspend {user.handle}; insufficient permissions"
- error: handleNotUnique

View File

@ -80,7 +80,7 @@ func TestApplicationCreateForbidden(t *testing.T) {
FormData("name", "my-app").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertError("not allowed to create application")).
Assert(helpers.AssertError("not allowed to create applications")).
End()
}
@ -106,7 +106,7 @@ func TestApplicationUpdateForbidden(t *testing.T) {
FormData("name", "changed-name").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertError("not allowed to update application")).
Assert(helpers.AssertError("not allowed to update this application")).
End()
}
@ -137,7 +137,7 @@ func TestApplicationDeleteForbidden(t *testing.T) {
Delete(fmt.Sprintf("/application/%d", a.ID)).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertError("not allowed to delete application")).
Assert(helpers.AssertError("not allowed to delete this application")).
End()
}

View File

@ -99,7 +99,7 @@ func TestOrganisationUpdateForbidden(t *testing.T) {
FormData("name", "changed-name").
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertError("Not allowed to update organisation")).
Assert(helpers.AssertError("Not allowed to update this organisation")).
End()
}
@ -134,7 +134,7 @@ func TestOrganisationDeleteForbidden(t *testing.T) {
Delete(fmt.Sprintf("/organisation/%d", a.ID)).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertError("Not allowed to delete organisation")).
Assert(helpers.AssertError("Not allowed to delete this organisation")).
End()
}

View File

@ -98,7 +98,7 @@ func TestRoleCreateForbidden(t *testing.T) {
FormData("name", rs()).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertError("not allowed to create role")).
Assert(helpers.AssertError("not allowed to create roles")).
End()
}
@ -150,7 +150,7 @@ func TestRoleUpdateForbidden(t *testing.T) {
FormData("email", h.randEmail()).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertError("not allowed to update role")).
Assert(helpers.AssertError("not allowed to update this role")).
End()
}
@ -186,7 +186,7 @@ func TestRoleDeleteForbidden(t *testing.T) {
Delete(fmt.Sprintf("/roles/%d", u.ID)).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertError("not allowed to delete role")).
Assert(helpers.AssertError("not allowed to delete this role")).
End()
}

View File

@ -245,7 +245,7 @@ func TestUserCreateForbidden(t *testing.T) {
FormData("email", h.randEmail()).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertError("not allowed to create user")).
Assert(helpers.AssertError("not allowed to create users")).
End()
}
@ -278,7 +278,7 @@ func TestUserUpdateForbidden(t *testing.T) {
FormData("email", h.randEmail()).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertError("not allowed to update user")).
Assert(helpers.AssertError("not allowed to update this user")).
End()
}
@ -311,7 +311,7 @@ func TestUserDeleteForbidden(t *testing.T) {
Delete(fmt.Sprintf("/users/%d", u.ID)).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertError("not allowed to delete user")).
Assert(helpers.AssertError("not allowed to delete this user")).
End()
}