Files
mesh/authentication_error.go
T

47 lines
1.1 KiB
Go

// Code generated by zi2go from authentication_error.zi. DO NOT EDIT.
package main
import (
errors "errors"
slog "log/slog"
)
// #import std_go_types
type AuthError struct {
Status int
Message string
}
func AuthenticationError_Message(error AuthError) string {
return error.Message
}
func (receiver AuthError) Error() string {
return AuthenticationError_Message(receiver)
}
func AuthenticationError_Convert(result AuthenticationResult) Error {
if result.Error != nil {
return result.Error
}
if result.Status != 0 {
var error AuthError = AuthError{}
error.Status = result.Status
error.Message = result.Message
return Error(error)
}
return nil
}
func AuthenticationError_Respond(writer ResponseWriter, counters **ServerMetrics, error Error) {
var failure AuthError = AuthError{}
if errors.As(error, Any(&(failure))) {
Metrics_RecordAuthFailure(*(counters), failure.Status, failure.Message)
Response_Error(writer, failure.Status, failure.Message)
return
}
slog.Error("auth", "error", error)
Metrics_RecordAuthFailure(*(counters), int(500), "authentication failed")
Response_Error(writer, int(500), "authentication failed")
}