Skip to content

Commit

Permalink
Renamed msg"" to m""
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jul 1, 2024
1 parent 96bb237 commit fbeb70b
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 48 deletions.
28 changes: 14 additions & 14 deletions src/core/nettlesome.EmailAddressError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import anticipation.*
import scala.compiletime.*

case class EmailAddressError(reason: EmailAddressError.Reason)
extends Error(msg"the email address is not valid because $reason")
extends Error(m"the email address is not valid because $reason")

object EmailAddressError:
enum Reason:
Expand All @@ -41,20 +41,20 @@ object EmailAddressError:

object Reason:
given Reason is Communicable =
case Empty => msg"it is empty"
case LongLocalPart => msg"the local part is more than 64 characters long"
case TerminalPeriod => msg"the local part ends in a period, which is not allowed"
case SuccessivePeriods => msg"the local part contains two adjacent periods"
case UnclosedQuote => msg"the quoted local part has no closing quote"
case MissingDomain => msg"the domain is missing"
case MissingAtSymbol => msg"the at-symbol is missing"
case InitialPeriod => msg"the local part starts with a period, which is not allowed"
case UnclosedIpAddress => msg"the domain begins with ${'['} but does not end with ${']'}"
case UnescapedQuote => msg"the local part contains a quote character which is not escaped"
case Empty => m"it is empty"
case LongLocalPart => m"the local part is more than 64 characters long"
case TerminalPeriod => m"the local part ends in a period, which is not allowed"
case SuccessivePeriods => m"the local part contains two adjacent periods"
case UnclosedQuote => m"the quoted local part has no closing quote"
case MissingDomain => m"the domain is missing"
case MissingAtSymbol => m"the at-symbol is missing"
case InitialPeriod => m"the local part starts with a period, which is not allowed"
case UnclosedIpAddress => m"the domain begins with ${'['} but does not end with ${']'}"
case UnescapedQuote => m"the local part contains a quote character which is not escaped"

case InvalidChar(char) =>
msg"the local part contains the character $char which is not allowed"
m"the local part contains the character $char which is not allowed"

case InvalidDomain(error) => error match
case error: IpAddressError => msg"the domain is not a valid IP address: ${error.message}"
case error: HostnameError => msg"the domain is not a valid hostname: ${error.message}"
case error: IpAddressError => m"the domain is not a valid IP address: ${error.message}"
case error: HostnameError => m"the domain is not a valid hostname: ${error.message}"
12 changes: 6 additions & 6 deletions src/core/nettlesome.HostnameError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ object HostnameError:

object Reason:
given Reason is Communicable =
case LongDnsLabel(label) => msg"the DNS label $label is longer than 63 characters"
case LongHostname => msg"the hostname is longer than 253 characters"
case InvalidChar(char) => msg"the character $char is not allowed in a hostname"
case EmptyDnsLabel(n) => msg"a DNS label cannot be empty"
case InitialDash(label) => msg"the DNS label $label begins with a dash which is not allowed"
case LongDnsLabel(label) => m"the DNS label $label is longer than 63 characters"
case LongHostname => m"the hostname is longer than 253 characters"
case InvalidChar(char) => m"the character $char is not allowed in a hostname"
case EmptyDnsLabel(n) => m"a DNS label cannot be empty"
case InitialDash(label) => m"the DNS label $label begins with a dash which is not allowed"

case class HostnameError(text: Text, reason: HostnameError.Reason)
extends Error(msg"the hostname is not valid because $reason")
extends Error(m"the hostname is not valid because $reason")
18 changes: 9 additions & 9 deletions src/core/nettlesome.IpAddressError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ object IpAddressError:

object Reason:
given Reason is Communicable =
case Ipv4ByteOutOfRange(byte) => msg"the number $byte is not in the range 0-255"
case Ipv4ByteNotNumeric(byte) => msg"the part $byte is not a number"
case Ipv6GroupNotHex(group) => msg"the group '$group' is not a hexadecimal number"
case Ipv6WrongNumberOfGroups(count) => msg"the address has $count groups, but should have 8"
case Ipv6MultipleDoubleColons => msg":: appears more than once"
case Ipv4ByteOutOfRange(byte) => m"the number $byte is not in the range 0-255"
case Ipv4ByteNotNumeric(byte) => m"the part $byte is not a number"
case Ipv6GroupNotHex(group) => m"the group '$group' is not a hexadecimal number"
case Ipv6WrongNumberOfGroups(count) => m"the address has $count groups, but should have 8"
case Ipv6MultipleDoubleColons => m":: appears more than once"

case Ipv4WrongNumberOfGroups(count) =>
msg"the address contains $count period-separated groups instead of 4"
m"the address contains $count period-separated groups instead of 4"

case Ipv6TooManyNonzeroGroups(count) =>
msg"the address has $count non-zero groups, which is more than is permitted"
m"the address has $count non-zero groups, which is more than is permitted"

case Ipv6GroupWrongLength(group) =>
msg"the group is more than 4 hexadecimal characters long"
m"the group is more than 4 hexadecimal characters long"

case class IpAddressError(reason: IpAddressError.Reason)
extends Error(msg"the IP address is not valid because $reason")
extends Error(m"the IP address is not valid because $reason")
8 changes: 4 additions & 4 deletions src/core/nettlesome.MacAddressError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ object MacAddressError:
object Reason:
given Reason is Communicable =
case WrongGroupCount(count) =>
msg"there should be six colon-separated groups, but there were $count"
m"there should be six colon-separated groups, but there were $count"

case WrongGroupLength(group, length) =>
msg"group $group should be two hex digits, but its length is $length"
m"group $group should be two hex digits, but its length is $length"

case NotHex(group, content) =>
msg"group $group should be a two-digit hex number, but it is $content"
m"group $group should be a two-digit hex number, but it is $content"


case class MacAddressError(reason: MacAddressError.Reason)
extends Error(msg"the MAC address is not valid because $reason")
extends Error(m"the MAC address is not valid because $reason")
6 changes: 3 additions & 3 deletions src/core/nettlesome.Nettlesome.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ object Nettlesome:
if bytes.length == 4 then
given IpAddressError mitigates NumberError =
case NumberError(text, _) => IpAddressError(Ipv4ByteNotNumeric(text))

bytes.map(Decoder.int.decode(_)).pipe: bytes =>
for byte <- bytes
do if !(0 <= byte <= 255) then raise(IpAddressError(Ipv4ByteOutOfRange(byte)))(0.toByte)
Expand Down Expand Up @@ -180,13 +180,13 @@ object Nettlesome:
val portNumber: Int = failCompilation(context.valueOrAbort.parts.head.tt.decodeAs[Int])

if 1 <= portNumber <= 65535 then '{TcpPort.unsafe(${Expr(portNumber)})}
else abandon(msg"the TCP port number ${portNumber} is not in the range 1-65535")
else abandon(m"the TCP port number ${portNumber} is not in the range 1-65535")

def udpPort(context: Expr[StringContext])(using Quotes): Expr[UdpPort] =
val portNumber: Int = failCompilation(context.valueOrAbort.parts.head.tt.decodeAs[Int])

if 1 <= portNumber <= 65535 then '{UdpPort.unsafe(${Expr(portNumber)})}
else abandon(msg"the UDP port number ${portNumber} is not in the range 1-65535")
else abandon(m"the UDP port number ${portNumber} is not in the range 1-65535")

def ip(context: Expr[StringContext])(using Quotes): Expr[Ipv4 | Ipv6] =
val text = Text(context.valueOrAbort.parts.head)
Expand Down
2 changes: 1 addition & 1 deletion src/core/nettlesome.OfflineError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ import fulminate.*

import language.experimental.captureChecking

case class OfflineError() extends Error(msg"an Internet connection is not available")
case class OfflineError() extends Error(m"an Internet connection is not available")
2 changes: 1 addition & 1 deletion src/core/nettlesome.PortError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ import anticipation.*

import IpAddressError.Reason, Reason.*

case class PortError() extends Error(msg"the port is not in the valid range")
case class PortError() extends Error(m"the port is not in the valid range")
12 changes: 6 additions & 6 deletions src/url/nettlesome.UrlError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import fulminate.*
import anticipation.*

case class UrlError(text: Text, offset: Int, expected: UrlError.Expectation)
extends Error(msg"the URL $text is not valid: expected $expected at $offset")
extends Error(m"the URL $text is not valid: expected $expected at $offset")

object UrlError:
enum Expectation:
case Colon, More, LowerCaseLetter, PortRange, Number

object Expectation:
given Expectation is Communicable =
case Colon => msg"a colon"
case More => msg"more characters"
case LowerCaseLetter => msg"a lowercase letter"
case PortRange => msg"a port range"
case Number => msg"a number"
case Colon => m"a colon"
case More => m"more characters"
case LowerCaseLetter => m"a lowercase letter"
case PortRange => m"a port range"
case Number => m"a number"
8 changes: 4 additions & 4 deletions src/url/nettlesome.UrlInterpolator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object UrlInterpolator extends contextual.Interpolator[UrlInput, Text, Url[Label
def insert(state: Text, value: UrlInput): Text = value match
case UrlInput.Integral(port) =>
if !state.ends(t":")
then throw InterpolationError(msg"a port number must be specified after a colon")
then throw InterpolationError(m"a port number must be specified after a colon")

try throwErrors(Url.parse(state+port.show)) catch
case err: UrlError => throw InterpolationError(Message(err.message.text))
Expand All @@ -58,7 +58,7 @@ object UrlInterpolator extends contextual.Interpolator[UrlInput, Text, Url[Label

case UrlInput.Textual(text) =>
if !state.ends(t"/")
then throw InterpolationError(msg"a substitution may only be made after a slash")
then throw InterpolationError(m"a substitution may only be made after a slash")

try throwErrors(Url.parse(state+text.urlEncode)) catch
case err: UrlError => throw InterpolationError(Message(err.message.text))
Expand All @@ -68,7 +68,7 @@ object UrlInterpolator extends contextual.Interpolator[UrlInput, Text, Url[Label

case UrlInput.RawTextual(text) =>
if !state.ends(t"/")
then throw InterpolationError(msg"a substitution may only be made after a slash")
then throw InterpolationError(m"a substitution may only be made after a slash")

try throwErrors(Url.parse(state+text.urlEncode)) catch
case err: UrlError => throw InterpolationError(Message(err.message.text))
Expand All @@ -80,7 +80,7 @@ object UrlInterpolator extends contextual.Interpolator[UrlInput, Text, Url[Label

def parse(state: Text, next: Text): Text =
if !state.empty && !(next.starts(t"/") || next.empty)
then throw InterpolationError(msg"a substitution must be followed by a slash")
then throw InterpolationError(m"a substitution must be followed by a slash")

state+next

Expand Down

0 comments on commit fbeb70b

Please sign in to comment.