Thrown by parseUrl() when a URL is malformed or uses an unknown scheme. This is the
only function in notifly that throws.
typescript
import { parseUrl, ParseError } from '@ambersecurityinc/notifly';try { const config = parseUrl('unknown://something');} catch (err) { if (err instanceof ParseError) { // URL was not recognised console.error('Parse error:', err.message); } else { // Unexpected error — re-throw throw err; }}
Note: You don't need to call parseUrl() directly when using
notify() — it handles parsing internally and returns errors in the
NotiflyResult.
ServiceError
ServiceError is thrown by a service's send() method when the upstream
API returns a non-2xx response. It's caught internally by notify() and converted to a
failed NotiflyResult.
typescript
class ServiceError extends Error { name: 'ServiceError'; status: number; // HTTP status code body: string; // Raw response body}
When building a custom service, you can throw
ServiceError for clean error propagation:
typescript
import { ServiceError } from '@ambersecurityinc/notifly';async function send(config, message) { const res = await fetch('https://api.myapp.com/notify', { method: 'POST', body: JSON.stringify({ text: message.body }), }); if (!res.ok) { const body = await res.text(); throw new ServiceError( `Upstream API error`, res.status, body ); } return { success: true, service: 'myapp' };}
Retry patterns
notifly doesn't retry automatically. For retry logic, wrap notify() yourself: